Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!goblin3!goblin.stu.neva.ru!newsfeed2.funet.fi!newsfeeds.funet.fi!news.helsinki.fi!.POSTED!not-for-mail From: Jussi Piitulainen Newsgroups: comp.lang.python Subject: Re: Something is rotten in Denmark... Date: 03 Jun 2011 09:17:11 +0300 Organization: University of Helsinki Lines: 21 Sender: jpiitula@ruuvi.it.helsinki.fi Message-ID: References: <2_AFp.30000$241.24052@newsfe07.iad> <4de71c42$0$29983$c3e8da3$5496439d@news.astraweb.com> <87zkm0qyze.fsf@dpt-info.u-strasbg.fr> <94qlhsFkriU1@mid.individual.net> <238bf9b2-fa07-4da3-b7a0-3bf07a6bd947@q12g2000prb.googlegroups.com> NNTP-Posting-Host: ruuvi.it.helsinki.fi Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: oravannahka.helsinki.fi 1307081832 14636 128.214.205.65 (3 Jun 2011 06:17:12 GMT) X-Complaints-To: usenet@oravannahka.helsinki.fi NNTP-Posting-Date: Fri, 3 Jun 2011 06:17:12 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6916 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]