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


_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to