Something is rotten in Denmark...

rusi rustompmody at gmail.com
Sun Jun 5 06:54:37 EDT 2011


On Jun 3, 11:17 am, Jussi Piitulainen <jpiit... at 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?



More information about the Python-list mailing list