Go to the Next or Previous section, the Detailed Contents, or the FS(E)L Home Page.


A.1.8 Lambda terms

Syntax

\ x1, ...xn @ x lambda term (nameless function)

Equivalences

The definition

f(x,y,z) = x+y+z

is equivalent to the definition

f = \ x, y, z @ x+y+z

Remarks

There is no direct way of defining an anonymous function with multiple branches. The same effect can be achieved by using a local definition and the above equivalence. Functions can both take functions as arguments and return them as results.

map(f)(s) = < f(x) | x <- s >
twice(n)  = n*2
assert map(\ n @ n+1)(<3,7,2>) == <4,8,3>
assert map(map(twice))(< <9,2>, <1> >) == < <18,4>, <2> >

The old (and much hated) syntax of `lambda x1, ...xn ldot x' for `\ x1, ...xn @ x' is still supported, but is deprecated.


Go to the Next or Previous section, the Detailed Contents, or the FS(E)L Home Page.