On Wed, Apr 23, 2008 at 9:08 PM, Alex Martelli <<a href="mailto:aleaxit@gmail.com">aleaxit@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Wed, Apr 23, 2008 at 6:47 PM, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
> On Wed, Apr 23, 2008 at 1:56 PM, Nicholas T <<a href="mailto:ntung@ntung.com">ntung@ntung.com</a>> wrote:<br>
><br>
> > It's obvious how to use LC's to replace map and filter, but what about<br>
> > reduce? It is one of my favorite functions.<br>
> ><br>
> > >>> time=1901248<br>
> > >>> reduce(lambda a, b: a[:-1] + [a[-1]%b, math.floor(a[-1]/b)], [[time],<br>
> > 60, 60, 24])<br>
> > [28, 7.0, 0.0, 22.0] # secs, mins, hrs, days<br>
><br>
> I recommend learning how to use a good old for-loop. That example is<br>
> as cryptic as can be. It's also inefficient due to calling a function<br>
> for each iteration.<br>
<br>
</div>I normally frown on "me too" posts, but this time I won't refrain from<br>
a loud "hear, hear!". "Clever" code is NOT a culturally positive trait<br>
in the Python community (differently from most language communities...<br>
and this is in fact one reason I love Python).<br>
<font color="#888888"><br>
Alex<br>
</font></blockquote></div><br>It wasn't only posted to be cryptic, it's one thing that's difficult to
write with a for loop without a lot of verbosity (at least I couldn't
figure out how to do it...).<br><font color="#888888">
<br>Nicholas</font><br>