On Wed, Apr 23, 2008 at 9:08 PM, Alex Martelli &lt;<a href="mailto:aleaxit@gmail.com">aleaxit@gmail.com</a>&gt; 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 &lt;<a href="mailto:guido@python.org">guido@python.org</a>&gt; wrote:<br>
&gt; On Wed, Apr 23, 2008 at 1:56 PM, Nicholas T &lt;<a href="mailto:ntung@ntung.com">ntung@ntung.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; &nbsp; &nbsp;It&#39;s obvious how to use LC&#39;s to replace map and filter, but what about<br>
&gt; &nbsp;&gt; reduce? It is one of my favorite functions.<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; &gt;&gt;&gt; time=1901248<br>
&gt; &nbsp;&gt; &gt;&gt;&gt; reduce(lambda a, b: a[:-1] + [a[-1]%b, math.floor(a[-1]/b)], [[time],<br>
&gt; &nbsp;&gt; 60, 60, 24])<br>
&gt; &nbsp;&gt; &nbsp;[28, 7.0, 0.0, 22.0] # secs, mins, hrs, days<br>
&gt;<br>
&gt; &nbsp;I recommend learning how to use a good old for-loop. That example is<br>
&gt; &nbsp;as cryptic as can be. It&#39;s also inefficient due to calling a function<br>
&gt; &nbsp;for each iteration.<br>
<br>
</div>I normally frown on &quot;me too&quot; posts, but this time I won&#39;t refrain from<br>
a loud &quot;hear, hear!&quot;. &quot;Clever&quot; 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&#39;t only posted to be cryptic, it&#39;s one thing that&#39;s difficult to
write with a for loop without a lot of verbosity (at least I couldn&#39;t
figure out how to do it...).<br><font color="#888888">
<br>Nicholas</font><br>