[pypy-svn] rev 707 - pypy/trunk/src/pypy/module

lac at codespeak.net lac at codespeak.net
Thu May 29 17:52:27 CEST 2003


Author: lac
Date: Thu May 29 17:52:27 2003
New Revision: 707

Modified:
   pypy/trunk/src/pypy/module/builtin_app.py
Log:
change reduce to not call its sequence 'list'


Modified: pypy/trunk/src/pypy/module/builtin_app.py
==============================================================================
--- pypy/trunk/src/pypy/module/builtin_app.py	(original)
+++ pypy/trunk/src/pypy/module/builtin_app.py	Thu May 29 17:52:27 2003
@@ -87,19 +87,23 @@
     return res
 
 
-def reduce(function, list, *initialt):
+def reduce(function, l, *initialt):
+    """ Apply function of two arguments cumulatively to the items of
+        sequence, from left to right, so as to reduce the sequence to a
+        single value."""
+    
     if initialt:
        initial, = initialt
        idx = 0
     else:
        try:
-          initial = list[0]
+          initial = l[0]
        except IndexError:
           raise TypeError, "reduce() of empty sequence with no initial value"
        idx = 1
     while 1:
        try:
-         initial = function(initial, list[idx])
+         initial = function(initial, l[idx])
          idx = idx + 1
        except IndexError:
          break


More information about the Pypy-commit mailing list