You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Lambda Functions

Lambda functions are actually the fundamental way in which Scheme defines a function:

(define (myFunc x y)
   (...))

is really just a Scheme shorthand for

(define myFunc (lambda x y)
   (...))

The only reason we ever give associate a name with something is if we wish to reference it more than once!

This means that everything that we done with functions already also applies to lambdas, since they are all the same thing.

The lambda function definition is useful when we want to define a function right where we use it.   (Most likely because we only need to use that function once.)

For instance, lambdas are very useful when calling higher-order functions such as filter, map, foldr, etc.:

(filter (lambda x) (...)) aList)

(map (lambda x) (...) aList)

(foldr (lambda aFirst aRecursiveResult)(...)) aList)
  • No labels