rusi writes:

> So I tried:
> Recast the comprehension as a map
> Rewrite the map into a fmap (functionalmap) to create new bindings
> 
> def fmap(f,lst):
>     if not lst: return []
>     return [f(lst[0])] + fmap(f, lst[1:])
> 
> Still the same effects.
> 
> Obviously I am changing it at the wrong place...

   >>> fs = [(lambda n : n + i) for i in range(10)]
   >>> [f(1) for f in fs]
   [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]

   >>> fs = list(map(lambda i : lambda n : n + i, range(10)))
   >>> list(map(lambda f : f(1), fs))
   [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to