>>>>> Tim Northover <t.p.northo...@sms.ed.ac.uk> (TN) escribió:

>TN> Steven D'Aprano <st...@remove-this-cybersource.com.au> writes:
>>> Calling all functional programming fans... is Python's built-in reduce() 
>>> a left-fold or a right-fold?

>TN> I get:

>>>>> reduce(lambda a, b: a/b, [1.0, 2.0, 3.0])
>TN> 0.16666666666666666

>TN> which looks like a left fold to me.

Yes, see the Haskell result:

Prelude> foldl (/) 1.0 [1.0, 2.0, 3.0]
0.16666666666666666
Prelude> foldr (/) 1.0 [1.0, 2.0, 3.0]
1.5

-- 
Piet van Oostrum <p...@cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to