[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: map/filter/reduce/lambda opinions and background unscientific
From: Paweł Sakowski <pawel () sakowski ! pl>
Date: 2005-07-07 15:08:31
Message-ID: dajghf$dit$1 () inews ! gazeta ! pl
[Download RAW message or body]
Tom Anderson wrote:
> def flatten(ll):
> return reduce(lambda a, l: a.extend(l), ll, [])
>
> How would one do that as a list comp, by the way? I'm really not very good
> with them yet.
Not really a list-comprehension based solution, but I think what you want is
>>> ll=[[1,2],[3,4,5],[6]]
>>> sum(ll,[])
[1, 2, 3, 4, 5, 6]
--
Paweł Sakowski <pawel@sakowski.pl>
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic