[Tutor] Lambdas

Alan Gauld alan.gauld at blueyonder.co.uk
Thu Jan 1 05:41:27 EST 2004

> Okay well I guess I chose I bad example for lambdas, but i cant find
> good tutorials on them on the web.

They are covered briefly in my titor in the functional
programming topic. But for a more in depth coverage you
will need to turn to tutorials on Lisp/Scheme or other
functional languages like Haskell.

Thre is a also whole branch of math dedicated to this too, known
as lamda calculus, and it is the theoretical underpinning of
functional programming (and indeed most other programming styles too)
It depends just how dep you want to go...

> Where is an in depth tutorial on lambdas. Even though there not all
> necessary

lambdas are fundamental and essential, but you don't need
to use the work "lambda" to create one. In Python most
function definitions can be thought of as a lambda:

def f(x): return g(x)

is identical to the lambda form

f = lambda x: g(x)

After either we can assign the function object to another variable:

h = f

and call h(5) or whatever. We can also pass the function object
to another function as a parameter etc... So the only use of lambda
in Python is for anonymous functions, and they can always be
got around with traditional function declarations.

But understanding the ideas behind lambdas is vitally important to
understanding the principles of good programming, in any language.

Alan G.

More information about the Tutor mailing list