Jeff Shannon wrote:

However, Python doesn't need lambdas to be able to write in a functional style. Functions are first-class objects and can be passed around quite easily, and IIRC Python's list comprehensions were borrowed (though probably with notable modification) from Haskell.



Note, it is haskell convention to name a list of objects with a plural. So xs -> list of x.


haskell:

[ x | x <- xs ]
[ foo x | x <- xs, x > 2 ]

python

[ x for x in xs ]
[ foo(x) for x in xs if x > 2 ]

shaleh
still mastering haskell, but loving it. Like python for functional languages.
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to