Mark Dickinson added the comment:
A couple of observations:
1. Haskell's (rough) equivalents would be `mapAccumL` and `mapAccumR`, which do
take an initializer [1]. The signature for both functions is something like:
(acc -> b -> (acc, c)) -> acc -> [b] -> (acc, [c]).
2. In the particular case of NumPy, I've found np.cumsum a pain to use on
multiple occasions because of the missing left-hand point in the result.
Grepping through a couple of recent (real-world) projects produces code like:
summed_widths = cumsum(hstack(([0], widths[:-1])))
and
cumulative_segments = np.insert(np.cumsum(segment_lengths), 0, 0.0)
where that extra missing value is having to be inserted either in the input
list or the output list. OTOH, none of those projects is natural fit for
itertools, so changing itertools wouldn't help them directly.
[1] https://www.haskell.org/hoogle/?hoogle=mapAccumL
----------
nosy: +mark.dickinson
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue25193>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com