Hi John,

> Everything is possible with list comprehensions!

>>> [x for z in a for y in z for x in y]
> [1, 2, 3, 31, 32, 4, 5, 6, 7, 71, 72, 8, 9]

impressive!

But in the general case can you do the same job as 
reduce in a list comprehension? ie apply an operation 
to the first two elements of a sequence and replace 
them with the result, then repeat until the list becomes 
a single value?

I cannot think of a way to do that in the generaln case 
with a comprehension. I'd be interested to see if there is a 
recipe for that.

Alan G

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to