The Python syntax is:
lambda <parameters> : <expression>
>>>plus1 = lambda x : x+1
>>>plus1( 2 )
>>>map( lambda x,y : x + y, range( 0, 10 ), [ 10 ] * 10 )
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
"lambda" is mentioned in the _latest_version_ of the Language Reference Manual:
section 5.9 "Boolean operations" ( page 29 in my copy - this one is in
the index under "lambda" )
section 7.5 "Function definitions" ( page 42, this one wasn't in my
index, but it was referenced in the entry above. )
In the Misc/NEWS file ( it was a new addition to 1.0 )
Tim said it was in the FAQ, but I didn't grep it.
Maybe he meant the NEWS file.
Map, filter, & reduce: new functions that can use "lambda" useful
are in the new version of the Library Reference Manual.
[ xrange is also mentioned in the Misc/NEWS file, but I didn't
see any mention of it in the library manual. ]
- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU>
- UVA Department of Molecular Physiology and Biological Physics