学习 Lambdas/Closures 的最佳独立于语言的资源是什么?

发布于 2024-08-18 10:41:35 字数 1398 浏览 4 评论 0原文

大多数编程语言都使用 lambda/闭包。 哪种语言无关的源被推荐为学习 Lambda 基础知识的最佳选择?

不同语言的 Lambda/Closures:

Most programming languages are utilizing lambdas/closures.
Which language agnostic source is recommended as the best to learn Lambda basics?

Lambdas/Closures in different languages:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

眼藏柔 2024-08-25 10:41:35

如果您只是想要一些易于理解的内容,请阅读Lambda 演算和方案简介。当然,它并不是与语言无关的,但Scheme 的实现非常接近。

如需更深入的了解,请阅读类型和编程语言 - Benjamin Pierce。编程语言理论以及对 lambda 演算的深入研究。完全与语言无关。

If you just want something easily digestible, read An Introduction to Lambda Calculus and Scheme. Of course it isn't language-agnostic, but Scheme's implementation is pretty close.

For a deeper understanding, read Types and Programming Languages - Benjamin Pierce. Programming language theory with a thorough study of the lambda calculus. Completely language-agnostic.

や莫失莫忘 2024-08-25 10:41:35

我认为 lambda 在 Lisp 中是最简单的,因为它是为这类事情而设计的,而在方言中,Scheme 往往是最简单的。

并非巧合的是,有史以来最伟大的计算机科学书籍使用了Scheme !这是SICP 对 lambda 的介绍。

I think lambda is simplest in Lisp, since it was designed for that kind of thing, and of the dialects, Scheme tends to be the simplest.

Not coincidentally, the greatest computer science book ever written uses Scheme! Here's SICP's introduction to lambdas.

熊抱啵儿 2024-08-25 10:41:35

Lambda 演算与语言无关。答案取决于你所说的“基础”是什么意思。一旦你选择了任何语言,你就失去了不可知论的要求。

JavaScript 有闭包。我也会将其添加到列表中。 Java 还没有。

我认为这最终会回到你打算使用它们的地方。如果你想保持老派的风格,请回到 Lisp 或Scheme,因为它们是源代码。如果您最终要在主流商业语言中使用 Javascript、C# 或 Python,请选择它们。

The Lambda Calculus is language agnostic. The answer depends on what you mean by "basics". The moment you choose any language you've lost your agnostic requirement.

Javascript has closures. I'd add that to the list as well. Java does not - yet.

I think it comes back to where you intend to use them eventually. Go back to Lisp or Scheme, since they're the source, if you want to be old school. Choose Javascript or C# or Python if you will end up using them in a mainstream commercial language.

离不开的别离 2024-08-25 10:41:35

对于想要学习理论基础的初学者来说,丹本对皮尔斯这本书的建议是无与伦比的。

但从您给出的列表来看,您想要的似乎是如何使用一流的函数值进行有效编程,这就是 lambda 的计算结果。您不会在与语言无关的包中获得这种经验、信息或直觉。更糟糕的是,在真实语言中,许多匿名函数是通过柯里化函数的部分应用而不是通过显式的 lambda 来创建的;大多数人大量使用一流函数,但发现 lambda 相当烦人且难以阅读。

以此为背景,这里有两条建议:

  • 如果您执意要学习lambda,请使用Scheme 做点什么。与许多其他函数式语言相比,Schemers 喜欢一流的函数,而Scheme 的表示法迫使程序员使用更明确的 lambda。

  • 作为初学者,您最好先了解为什么人们想要使用这些一流的函数。在这种情况下,请阅读 John Hughes 撰写的为什么函数式编程很重要。休斯的论文使用的符号在某种程度上与语言无关;它不是任何当前流行语言的表示法,但它有点类似于 Caml、F#、Haskell 和 ML。

For a beginner wanting to learn the theoretical foundations, danben's suggestion of Pierce's book is unbeatable.

But from the list you give, it sounds like what you want is how to program effectively with first-class function values, which is what lambda evaluates to. You're not going to get this experience, information, or intuition in a language-agnostic package. Worse, in real languages many anonymous functions are created through partial application of Curried functions rather than through explicit lambda; most people use first-class functions heavily find lambdas rather annoying and hard to read.

With that as background, here are two pieces of advice:

  • If you're dead set on learning about lambda, do something with Scheme. Schemers like first-class functions, and Scheme's notation forces more explicit lambdas on the programmer than many other functional languages.

  • As a beginner, you may be better off learning why people want to use these first-class functions to begin with. In that case, read Why Functional Programming Matters by John Hughes. Hughes's paper uses a notation that is somewhat language-agnostic; it is not the notation of any currently popular language, but it is somewhat similar to Caml, F#, Haskell, and ML.

失与倦" 2024-08-25 10:41:35

首先,我不会将它们作为“独立于语言”的东西来学习。我建议首先在 Javascript 中使用它们,然后扩展到另一种语言(如 lisp、C#),实际学习它们。然后,如果您觉得需要更进一步,请学习一般理论知识。

I wouldn't learn them as a "language independent" thing, first. I'd recommend learning them practically, by using them in Javascript first, then broadening to another language (like lisp, C#). Then, if you feel the need to go further, learn the general theoretical stuff.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文