No trace of cumulativeFold except in the source.

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Oct 23 02:11:08 PDT 2016


On Sunday, October 23, 2016 07:46:19 e-y-e via Digitalmars-d-learn wrote:
> Recently I needed to use a cumulative sum function, so I looked
> in phobos' documentation for 'cumulative' but found nothing
> useful. Then I looked in the forums for it and found nothing
> useful. But when I searched phobos for it I found cumulativeFold
> in std.algorithm.iteration:
> https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d#L312
> 7. So I tried this:
>
> auto cumulativeSum(Range)(Range r)
> {
>      import std.algorithm.iteration : cumulativeFold;
>
>      return r.cumulativeFold!((a, b) => a +b);
> }
>
> but when I run it I get 'Error: module std.algorithm.iteration
> import 'cumulativeFold' not found'. Anyone can reproduce this?
> looking at the source I can't see how it could possibly occur but
> it is certainly a bug right?

It's not a bug. It's just too new. You looked at the master branch on
github, whereas what you're probably using on your computer is 2.071.2,
which does not have cumulativeFold, because it was added at some point after
2.071.2.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list