[Python-ideas] Add nullifier argument to functools.reduce?

Warren Weckesser warren.weckesser at gmail.com
Sun Aug 24 16:47:02 CEST 2014


On Sun, Aug 24, 2014 at 12:24 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> On 24 August 2014 01:30, Warren Weckesser <warren.weckesser at gmail.com>
> wrote:
> > I'd like to add an additional optional argument to functools.reduce.
> > The argument is the "nullifier" of the reducing operation.  It is a value
> > such that function(nullifier, anything) returns nullifier.  For example,
> if
> > function(x, y) computes x*y, the nullifier is 0.  If function(x, y) is
> > the intersection of the sets x and y, the nullifier is the empty set.
>
> When it comes to judging the usefulness of functional programming
> features these days, my first question is generally going to be "Does
> PyToolz offer this?"
>


I took a look, and I couldn't find it there.



>
> Grumblings about the name aside, it's still the solution I recommend
> to folks that wish Python had more functional programming tools in the
> standard library: http://toolz.readthedocs.org/en/latest/api.html
>
> There's even a Cython accelerated version available (Cytoolz).
>
> "pip install toolz" for the pure Python version, "pip install cytoolz"
> for the accelerated one.
>
> Cheers,
> Nick.
>
> --
> Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140824/ceb1c4fd/attachment.html>


More information about the Python-ideas mailing list