Functional programming with python
united-coders.com
united-coders.com
Not really. It is not too difficult to actually define a named function and the code usually ends up being easier to read/understand so that lack of multi-line lambdas is not a serious problem. Additionally, now that map and filter return iterators they are a bit more flexible than they used to be. OTOH, if you are using map and filter in your python code you should probably take a close look at what you are attempting to accomplish and see if a generator expression might do the job better.
map(f,lst) = [f(x) for x in lst]
filter(f,lst) = [x for x in lst if f(x)]
But I don't see a way to translate reduce, except for perhaps the particular case of sum. reduce(f,lst) = ???See Guido's explanation at: http://www.artima.com/weblogs/viewpost.jsp?thread=98196
And yes, a list comprehension produce a list with the same length, reduce not.