[BangPypers] List Comprehensions Vs. map/filter (Was: if not with comparision statement in python)

2011-08-01 Thread Anand Chitipothu
I knew there was a way to better implement flatmap - its a combination of itertools.chain.from_iterable and map. Here's a much cleaner code from itertools import chain print filter(lambda (x,y,z) : x*x + y*y == z*z,    chain.from_iterable(map(        lambda x: chain.from_iterable(map(    

Re: [BangPypers] List Comprehensions Vs. map/filter (Was: if not with comparision statement in python)

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 8:30 PM, Anand Chitipothu anandol...@gmail.com wrote: I knew there was a way to better implement flatmap - its a combination of itertools.chain.from_iterable and map. Here's a much cleaner code from itertools import chain print filter(lambda (x,y,z) : x*x + y*y == z*z,

Re: [BangPypers] List Comprehensions Vs. map/filter (Was: if not with comparision statement in python)

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 8:30 PM, Anand Chitipothu anandol...@gmail.com wrote: I was trying to translate Python list-comprehensions into Javascript and here is what I've come up with. $pyjs.listcomp(    function(x, y, z) { return [x, y, z]},    [        range(1, 100),        function(x) {