[Tutor] List comprehension

Kirby Urner urnerk@qwest.net
Wed, 23 Jan 2002 10:10:07 -0800


>
>(And I'm sure that someone will argue that lambdas aren't
>counterintuitive, but that's how I, and apparently more
>than a few others, have always found them.)
>
>Jeff Shannon
>Technician/Programmer
>Credit International

Well, they don't have to be mutually exclusive (lambdas and
list comprehensions).

Just for fun:

  >>> [apply(eval(x),(y,)) for x in \
         ["lambda x: x*x","lambda x: x*x*x"] \
         for y in [1,2,3]]

  [1, 4, 9, 1, 8, 27]

(groan)

Kirby