[Raymond Hettinger <raymond.hettin...@gmail.com>]
> Q. Do other languages do it?
> A. Numpy, no. R, no. APL, no. Mathematica, no. Haskell, yes.
>
>     * 
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.ufunc.accumulate.html
>     * https://stat.ethz.ch/R-manual/R-devel/library/base/html/cumsum.html
>     * http://microapl.com/apl/apl_concepts_chapter5.html
>       \+ 1 2 3 4 5
>       1 3 6 10 15
>     * https://reference.wolfram.com/language/ref/Accumulate.html
>     * https://www.haskell.org/hoogle/?hoogle=mapAccumL

There's also C++, which is pretty much "yes" to every variation
discussed so far:

* partial_sum() is like Python's current accumulate(), including
defaulting to doing addition.

http://en.cppreference.com/w/cpp/algorithm/partial_sum

* inclusive_scan() is also like accumulate(), but allows an optional
"init" argument (which is returned if specified), and there's no
guarantee of "left-to-right" evaluation (it's intended for associative
binary functions, and wants to allow parallelism in the
implementation).

http://en.cppreference.com/w/cpp/algorithm/inclusive_scan

* exclusive_scan() is like inclusive_scan(), but _requires_ an "init"
argument (which is not returned).

http://en.cppreference.com/w/cpp/algorithm/exclusive_scan

* accumulate() is like Python's functools.reduce(), but the operation
is optional and defaults to addition, and an "init" argument is
required.

http://en.cppreference.com/w/cpp/algorithm/accumulate
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to