Ask Your Question

Revision history [back]

Short answer : lambda is used to create short and anonymous Python functions. For example, instead of writing:

sage: def inc(n):
....:     return n+1

You can write:

 sage: inc = lambda x : x+1

but lambda x : x+1 can be used directly in your code, without needing to name it inc, while the def construction require to give a name and use return

Longer answer :