On Jun 3, 11:17 am, Jussi Piitulainen <jpiit...@ling.helsinki.fi>
wrote:
> 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]

Thanks Jussi for that code -- but I am not fully able to wrap my head
around it.

Is the problem in the lambda? ZF?
Are you trying to say that map works (functionally) and ZF is
imperative?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to