Thread overview
No trace of cumulativeFold except in the source.
Oct 23, 2016
e-y-e
Oct 23, 2016
Jonathan M Davis
Oct 23, 2016
e-y-e
Oct 23, 2016
Jonathan M Davis
Oct 23, 2016
e-y-e
Oct 27, 2016
Jonathan M Davis
October 23, 2016
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#L3127. 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?
October 23, 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

October 23, 2016
On Sunday, 23 October 2016 at 09:11:08 UTC, Jonathan M Davis wrote:
> On Sunday, October 23, 2016 07:46:19 e-y-e via Digitalmars-d-learn wrote:
>> ...
>
> 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

Ok, that checks out. I looked at the commit and it was in April so I just assumed it would be in the release by now.
October 23, 2016
On Sunday, October 23, 2016 10:10:40 e-y-e via Digitalmars-d-learn wrote:
> On Sunday, 23 October 2016 at 09:11:08 UTC, Jonathan M Davis
>
> wrote:
> > On Sunday, October 23, 2016 07:46:19 e-y-e via
> >
> > Digitalmars-d-learn wrote:
> >> ...
> >
> > 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
>
> Ok, that checks out. I looked at the commit and it was in April so I just assumed it would be in the release by now.

Per

http://dlang.org/changelog/2.071.0.html

2.071.0 came out at the beginning of April, and 2.072 has been slow in coming, so we've only had point releases since then, and a new function would not be added with a point release. But yes, per the current release scheme, normally, there would have been a new major release by now (it is finally in beta though).

- Jonathan M Davis

October 23, 2016
On Sunday, 23 October 2016 at 10:19:07 UTC, Jonathan M Davis wrote:
> On Sunday, October 23, 2016 10:10:40 e-y-e via Digitalmars-d-learn wrote:
>> ...
>
> Per
>
> http://dlang.org/changelog/2.071.0.html
>
> 2.071.0 came out at the beginning of April, and 2.072 has been slow in coming, so we've only had point releases since then, and a new function would not be added with a point release. But yes, per the current release scheme, normally, there would have been a new major release by now (it is finally in beta though).
>
> - Jonathan M Davis

On this topic, do you think a 'cumulativeSum' specialisation based on the 'sum' specialisation be welcome in phobos? Here's a quick prototype, obviously not library standard but the basic logic is there: https://gist.github.com/anonymous/4fb79b4aba79b59348273288993740cb
October 27, 2016
On Sunday, October 23, 2016 19:20:43 e-y-e via Digitalmars-d-learn wrote:
> On this topic, do you think a 'cumulativeSum' specialisation based on the 'sum' specialisation be welcome in phobos? Here's a quick prototype, obviously not library standard but the basic logic is there: https://gist.github.com/anonymous/4fb79b4aba79b59348273288993740cb

If you think that it would be generally useful and worth having in Phobos, by all means, get it up to snuff for inclusion in Phobos and create a PR for it.

- Jonathan M Davis