[Numpy-discussion] Simple multi-arg wrapper for dot()

Alan G Isaac aisaac@american....
Sat Mar 24 14:36:15 CDT 2007


On Sun, 25 Mar 2007, Bill Baxter apparently wrote: 
> So if one just 
> changes the example to 
>   reduce(lambda s, a: s * a.myattr, data, 1) 
> How does one write that in a simplified way using generator 
> expressions without calling on reduce? 


Eliminating the expressiveness of ``reduce`` has in my 
opinion never been publically justified.

E.g., ::

    #evaluate polynomial (coefs=[an,...,a0]) at x
    # using Horner's rule
    def horner(coefs, x):
        return reduce(lambda a1,a0: a1*x+a0, coefs)

I suspect that ``reduce`` remains in danger only because the 
math community has been too quiet.

Cheers,
Alan Isaac




More information about the Numpy-discussion mailing list