Jump to page: 1 25  
Page
Thread overview
reduce -> fold?
Jan 29, 2016
Adrian Matoga
Jan 29, 2016
Luís Marques
Jan 29, 2016
Dragos Carp
Jan 29, 2016
Luís Marques
Feb 01, 2016
Dragos Carp
Feb 04, 2016
Walter Bright
Feb 04, 2016
Dragos Carp
Feb 05, 2016
Dragos Carp
Feb 04, 2016
John Colvin
Jan 30, 2016
Timon Gehr
Jan 29, 2016
Walter Bright
Jan 29, 2016
Walter Bright
Jan 30, 2016
deadalnix
Jan 30, 2016
Xinok
Jan 30, 2016
David Nadlinger
Feb 10, 2016
Jakob Ovrum
Jan 30, 2016
bachmeier
Jan 30, 2016
Vladimir Panteleev
Jan 29, 2016
Y
Jan 29, 2016
ixid
Jan 29, 2016
wobbles
Jan 29, 2016
Brad Anderson
Jan 29, 2016
Edwin van Leeuwen
Jan 29, 2016
Walter Bright
Jan 29, 2016
Walter Bright
Jan 29, 2016
bachmeier
Jan 29, 2016
Chris Wright
Jan 29, 2016
deadalnix
Jan 29, 2016
H. S. Teoh
Feb 02, 2016
Atila Neves
Feb 02, 2016
Atila Neves
Feb 03, 2016
Atila Neves
Feb 03, 2016
Atila Neves
Feb 03, 2016
Timon Gehr
Feb 03, 2016
John Colvin
Feb 03, 2016
H. S. Teoh
Feb 04, 2016
Atila Neves
Feb 04, 2016
Timon Gehr
Feb 29, 2016
Atila Neves
January 29, 2016
As has been discussed before there's been discussion about std.algorithm.reduce taking the "wrong" order of arguments (its definition predates UFCS). I recall the conclusion was there'd be subtle ambiguities if we worked reduce to implement both orders.

So the next best solution is to introduce a new name such as the popular "fold", and put them together in the documentation.


Thoughts?

Andrei
January 29, 2016
On Friday, 29 January 2016 at 12:08:01 UTC, Andrei Alexandrescu wrote:
> As has been discussed before there's been discussion about std.algorithm.reduce taking the "wrong" order of arguments (its definition predates UFCS). I recall the conclusion was there'd be subtle ambiguities if we worked reduce to implement both orders.
>
> So the next best solution is to introduce a new name such as the popular "fold", and put them together in the documentation.
>
>
> Thoughts?

YES!

There was a topic on this [1] and some implementation proposed. I'm not sure if it was the only one.

[1] http://forum.dlang.org/post/sqbizjwcyavbrxwagnwl@forum.dlang.org

January 29, 2016
On Friday, 29 January 2016 at 12:08:01 UTC, Andrei Alexandrescu wrote:
> So the next best solution is to introduce a new name such as the popular "fold", and put them together in the documentation.

Just to bikeshed a little, I remember that when I first started using std.algorithm I was ctrl-F'ing for "accumulate" and not finding it quite often. D competes with C++ directly, so do consider that name :-)
January 29, 2016
On Friday, 29 January 2016 at 13:11:34 UTC, Luís Marques wrote:
> Just to bikeshed a little, I remember that when I first started using std.algorithm I was ctrl-F'ing for "accumulate" and not finding it quite often. D competes with C++ directly, so do consider that name :-)

But not in python, where "accumulate"[1] is the generic equivalent of C++ "partial_sum"[2]. I like "fold" more.

BTW this week, a colleague of mine implemented a python "accumulate" in D. Is there any interest to contribute it to Phobos? How should this be named?

[1] https://docs.python.org/3/library/itertools.html#itertools.accumulate
[2] http://en.cppreference.com/w/cpp/algorithm/partial_sum
January 29, 2016
On Friday, 29 January 2016 at 13:56:48 UTC, Dragos Carp wrote:
> But not in python, where "accumulate"[1] is the generic equivalent of C++ "partial_sum"[2]. I like "fold" more.
>
> BTW this week, a colleague of mine implemented a python "accumulate" in D. Is there any interest to contribute it to Phobos? How should this be named?
>
> [1] https://docs.python.org/3/library/itertools.html#itertools.accumulate
> [2] http://en.cppreference.com/w/cpp/algorithm/partial_sum

Fair enough. Yes, that is indeed a useful algorithm, so please do contribute. I won't bikeshed on that other name, heh.
January 29, 2016
On Friday, 29 January 2016 at 12:08:01 UTC, Andrei Alexandrescu wrote:
> As has been discussed before there's been discussion about std.algorithm.reduce taking the "wrong" order of arguments (its definition predates UFCS). I recall the conclusion was there'd be subtle ambiguities if we worked reduce to implement both orders.
>
> So the next best solution is to introduce a new name such as the popular "fold", and put them together in the documentation.
>
>
> Thoughts?
>
> Andrei

Yes yes yes please!
January 29, 2016
On Friday, 29 January 2016 at 12:08:01 UTC, Andrei Alexandrescu wrote:
> As has been discussed before there's been discussion about std.algorithm.reduce taking the "wrong" order of arguments (its definition predates UFCS). I recall the conclusion was there'd be subtle ambiguities if we worked reduce to implement both orders.
>
> So the next best solution is to introduce a new name such as the popular "fold", and put them together in the documentation.
>
>
> Thoughts?
>
> Andrei

Absolutely yes!
January 29, 2016
On Friday, 29 January 2016 at 12:08:01 UTC, Andrei Alexandrescu wrote:
> As has been discussed before there's been discussion about std.algorithm.reduce taking the "wrong" order of arguments (its definition predates UFCS). I recall the conclusion was there'd be subtle ambiguities if we worked reduce to implement both orders.
>
> So the next best solution is to introduce a new name such as the popular "fold", and put them together in the documentation.
>
>
> Thoughts?
>
> Andrei

I think yes. Took me ages to realise the difference with reduce.
January 29, 2016
On Friday, 29 January 2016 at 12:08:01 UTC, Andrei Alexandrescu wrote:
> As has been discussed before there's been discussion about std.algorithm.reduce taking the "wrong" order of arguments (its definition predates UFCS). I recall the conclusion was there'd be subtle ambiguities if we worked reduce to implement both orders.
>
> So the next best solution is to introduce a new name such as the popular "fold", and put them together in the documentation.
>
>
> Thoughts?
>
> Andrei

+1

Let's make sure to write the half dozen other names for it in the documentation so people coming to D from other languages can easily find it.

And just for completeness, here is monarchdodra's valiant but ultimately unsuccessful pull request which attempted fix reduce: https://github.com/D-Programming-Language/phobos/pull/861#issuecomment-20760448
January 29, 2016
On Friday, 29 January 2016 at 16:38:23 UTC, Brad Anderson wrote:
> And just for completeness, here is monarchdodra's valiant but ultimately unsuccessful pull request which attempted fix reduce: https://github.com/D-Programming-Language/phobos/pull/861#issuecomment-20760448

Interestingly, that pull request links to another pull request which introduces fold, so we can just merge that one :) ?
https://github.com/D-Programming-Language/phobos/pull/2033
« First   ‹ Prev
1 2 3 4 5