[Tutor] Alternative to nested loops
Steve Nelson
sanelson at gmail.com
Sun Mar 19 23:44:23 CET 2006
On 3/19/06, Karl Pflästerer <khp at pflaesterer.de> wrote:
>>> reduce(lambda s, L: s + sum(L), foo, 0)
Ah ok - well that looks pretty cryptic to me, as I've never used
either lambda or reduce(). However, this looks to be a 'functional'
way of doing what I was doing procedurally, which is, I suppose, what
I was asking.
Would you mind helping to explain how the above works?
Incidentally, I had a look at:
http://www-128.ibm.com/developerworks/linux/library/l-prog.html
As an introduction to functional programming in Python - it looks
interesting. I've never done any functional programming at all, so it
all seems a little foreign!
Can you recommend another gentle introduction? Or will this fry my
brain, as I start trying to mix methodologies?
Thanks!
S.
More information about the Tutor
mailing list