reduce()--what is it good for?

Anton Vredegoor anton at vredegoor.doge.nl
Sat Nov 8 09:13:00 EST 2003


anton at vredegoor.doge.nl (Anton Vredegoor) wrote:

>    def factorial(x):
>        b = _Memo.biggest
>        if x > b: return reduce(mymul, xrange(b+1,x+1), b)
>        return _Memo.facdict[x]

Sorry, this part should be:

    def factorial(x):
        b = _Memo.biggest
        if x > b: 
            start = _Memo.facdict[b]
            return reduce(mymul, xrange(b+1,x+1), start)
        return _Memo.facdict[x]




More information about the Python-list mailing list