map/filter/reduce/lambda opinions and background unscientific mini-survey
twic at urchin.earth.li
Tue Jul 5 15:01:04 CEST 2005
On Mon, 4 Jul 2005, George Sakkis wrote:
> "Tom Anderson" <twic at urchin.earth.li> wrote:
>> I'll just chip in and say i'd quite like a flatten(), too; at the moment,
>> i have one like this:
>> def flatten(ll):
>> return reduce(lambda a, l: a.extend(l), ll, )
> This doesn't work; a.extend() returns None, not the extended list a:
Ah, no, very good, i was hoping someone would notice that. Well done.
I think my lambda looks more like lambda a, b: a + b, but i realised the
other day that extend could make it more efficient, and didn't think it
The revolution will not be televised. The revolution will be live.
More information about the Python-list