reduce -> fold?

Jakob Ovrum via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 10 10:43:53 PST 2016


On Saturday, 30 January 2016 at 18:08:00 UTC, David Nadlinger 
wrote:
> Currying is turning (A, B, C) -> D into A -> (B -> (C -> D)), 
> i.e. a function with multiple arguments into a sequence of 
> functions that each take a single argument to apply each.
>
> I think I've implemented something like that for fun once, but 
> never really found much use for it. In the few places where I 
> could have used it (mostly binary functions), just using a 
> lambda and partial application seemed to be much more 
> idiomatic. I guess D lacks any idioms that would make its use 
> come naturally.
>
>  - David

I'm late to the party, but I wrote these novetly tidbits a few 
months ago:

Curry using nested structs
https://gist.github.com/JakobOvrum/8b2cd11b911079735b14

Curry using delegates
https://gist.github.com/JakobOvrum/1a19f670e7a3359006af

Neither approach seems to fit in with idiomatic D.



More information about the Digitalmars-d mailing list