Lists of lists traversal

Magnus L. Hetland mlh at vier.idi.ntnu.no
Tue Dec 21 12:35:33 EST 1999


cjc26 at nospam.cornell.edu (Cliff Crawford) writes:

> Pada 20 Dec 1999 21:17:27 GMT, Kaleissin bilang:
[...]
> 
> [reduce(lambda x, y: x+y, l) for l in list_of_lists]

While we are simplifying... (Having imported add from operator):

[reduce(add,l) for l in lost_of_lists]

I must say - for single iterators, where there seems to be little
controversy over syntax - this list comprehension stuff can be really
neat :)

Although - for those who haven't installed it (like me), this works
nicely:

map(lambda l: reduce(add,l), list_of_lists)

--

  Magnus
  Lie
  Hetland



More information about the Python-list mailing list