# Lambda abstraction

### From HaskellWiki

(Difference between revisions)

m |
m |
||

(2 intermediate revisions by 2 users not shown) | |||

Line 1: | Line 1: | ||

− | A ''lambda abstraction'' is another name for an [[anonymous function]]. It gets its name from the usual notation for writing it - for example, <math>\lambda x \to x^2</math>. (Note: some sources write it as <math>\lambda x . \ x^2</math>.) |
+ | [[Category:Glossary]] |

+ | {{Foundations infobox}} |
||

+ | A ''lambda abstraction'' is another name for an [[anonymous function]]. It gets its name from the usual notation for writing it: for example, <math>\lambda x \to x^2</math>. (Another common, equivalent notation is: <math>\lambda x . \ x^2</math>.) |
||

− | In Haskell source code, the Greek letter lambda is replaced by a backslash character ('<hask>\</hask>') 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 '<hask>-></hask>'. So, for example, the lambda abstraction above would be written in Haskell as |
+ | In Haskell source code, the Greek letter lambda is replaced by a backslash character ('<hask>\</hask>') instead, since this is easier to type and requires only the basic 7-bit ASCII character set. Similarly, the arrow is replaced with the ASCII character sequence '<hask>-></hask>'. So, for example, the lambda abstraction above would be written in Haskell as |

<haskell> |
<haskell> |
||

Line 7: | Line 7: | ||

</haskell> |
</haskell> |
||

− | 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. |
+ | 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, <math>(\lambda x \to x^2 ) \ 7</math> - the result of the expression is determined by replacing every occurrence of the parameter variable (in this case <math>x</math>) with the parameter value (in this case 7). This is an [[Eta conversion|eta reduction]]. |
+ | When a lambda abstraction is applied to a value—for instance, <math>(\lambda x \to x^2 ) \ 7</math>—the result of the expression is determined by replacing every [[free variable|free occurrence]] of the parameter variable (in this case <math>x</math>) with the parameter value (in this case <math>7</math>). This is a [[Beta reduction|beta reduction]]. |

## Latest revision as of 19:54, 13 July 2007

A *lambda abstraction* is another name for an anonymous function. It gets its name from the usual notation for writing it: for example, . (Another common, equivalent notation is: .)

\

->

\ 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 free occurrence of the parameter variable (in this case *x*) with the parameter value (in this case 7). This is a beta reduction.