<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 24/10/2016 06:11, Danilo J. S.
Bellini wrote:<br>
</div>
<blockquote
cite="mid:CA+g5JwiDdT4EqVgPJ65sTeVaSyri6epEUYFJkwEwff66Re83OQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div> For example, a product:<br>
<div><br>
</div>
<div><span style="font-family:monospace,monospace">>>>
[prev * k for k in [5, 2, 4, 3] from prev = 1]<br>
[1, 5, 10, 40, 120]</span><br>
</div>
<div><br>
</div>
<div>That makes sense for me, and seem simpler than:<br>
<br>
</div>
<div><span style="font-family:monospace,monospace">>>>
from itertools import accumulate, chain<br>
</span></div>
<div>
<div><span style="font-family:monospace,monospace">>>>
list(accumulate(chain([1], [5, 2, 4, 3]), lambda prev,
k: prev * k))<br>
[1, 5, 10, 40, 120]</span><br>
<br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
Well, if you want an instant reaction from someone skimming this
thread: I looked at the first example and couldn't understand it.
Then I looked at the second one, and could understand it (even
though I may never have used "chain" or heard of "accumulate").
Obviously your mileage varies.<br>
Best wishes,<br>
Rob Cliffe<br>
<br>
</body>
</html>