[EMAIL PROTECTED] wrote:

>> def ireduce(op, iterable, *init):
>>     iterable = chain(init, iterable)
>>     accu = iterable.next()
>>     yield accu
>>     for item in iterable:
>>         accu = op(accu, item)
>>         yield accu

> I believe there is only one initializer in reduce. 

Throw in a 

if len(init) > 1: raise TypeError

for increased similarity to reduce(). 

> Also it is possible to not provide it.

Try it. 

Peter

PS: Did I mention that I prefer for-loops over reduce() most of the time?


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to