Message251220
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 |
|
Date |
User |
Action |
Args |
2015-09-21 12:09:07 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, achampion |
2015-09-21 12:09:07 | mark.dickinson | set | messageid: <1442837347.6.0.593968404253.issue25193@psf.upfronthosting.co.za> |
2015-09-21 12:09:07 | mark.dickinson | link | issue25193 messages |
2015-09-21 12:09:07 | mark.dickinson | create | |
|