Lambda abstraction

From HaskellWiki
Revision as of 17:24, 3 February 2007 by MathematicalOrchid (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

A lambda abstraction is another name for an anonymous function. It gets its name from the usual notation for writing it - for example, . (Note: some sources write it as .)

In Haskell source code, the Greek letter lambda is replaced by a backslash character ('\') instead, since this is easier to type. (And requires only the basic 7-bit ASCII character set.) Similarly, the arrow is replaced with the much more ugly character sequence '->'. So, for example, the lambda abstraction above would be written in Haskell as

  \ x -> x * x

There is actually a whole mathematical theory devoted to expressing computation entirely using lambda abstractions - the lambda calculus. Most functional programming languages (including Haskell) are based upon some extension of this idea.

When a lambda abstraction is applied to a value - for instance, - the result of the expression is determined by replacing every occurrence of the parameter variable (in this case ) with the parameter value (in this case 7). This is an eta reduction.