Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best language independent source to learn Lambdas/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:

  • Perl Lambdas
  • Python Lambdas
  • .Net LINQ
  • Java Closures
  • Scheme
  • Lisp
  • Php Closure and Lambdas
  • Javascript Closures
  • C++
  • ML
  • Wikipedia: Closures (computer science)
like image 539
Kb. Avatar asked Jan 16 '10 17:01

Kb.


People also ask

Are Java lambdas closures?

Java supports lambda expressions but not the Closures. A lambda expression is an anonymous function and can be defined as a parameter. The Closures are like code fragments or code blocks that can be used without being a method or a class.

Are lambdas the same as closures?

Lambda functions may be implemented as closures, but they are not closures themselves. This really depends on the context in which you use your application and the environment. When you are creating a lambda function that uses non-local variables, it must be implemented as a closure.

What is lambda programming language?

A lambda language, in simple terms, is a language that allows passing a function to another function, where the function is treated as any other variable. Also, you should be able to define this function to be passed anonymously (or inline). PHP 5.3 added support for lambda functions.

Does lambda calculus have closures?

Syntactically, lambda refers to a form for describing anonymous functions. But, a lambda does not become a function pointer. It becomes a closure. Closures are data structures with both a code and a data component.


2 Answers

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.

like image 136
danben Avatar answered Sep 29 '22 16:09

danben


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.

like image 22
Ken Avatar answered Sep 29 '22 16:09

Ken