Seed Value for reduce function
Vino
vino.bheeman at hotmail.com
Sun Dec 10 02:19:34 UTC 2017
On Sunday, 10 December 2017 at 01:42:46 UTC, Jonathan M Davis
wrote:
> On Sunday, December 10, 2017 00:39:07 Vino via
> Digitalmars-d-learn wrote:
>> [...]
>
> So, basically, you're trying to use reduce with UFCS, and that
> doesn't work in the case where you want to provide an explicit
> seed value? In that's the case, then use fold:
>
> https://dlang.org/phobos/std_algorithm_iteration.html#fold
>
> reduce predates UFCS in the language, so there wasn't really a
> reason to prefer having the range as the first argument at the
> time. fold has since been added to fix that problem. They're
> identical except for the order of arguments (in fact, fold just
> calls reduce internally).
>
> - Jonathan M Davis
Hi Jonathan,
Tried with fold even then it is failing same as reduce with the
same error when there is empty folder
auto SdFiles = Array!ulong(dirEntries(d, SpanMode.depth).map!(a
=> a.size).fold!((a,b) => a + b))[].filter!(a => a > Size);
From,
Vino.B
More information about the Digitalmars-d-learn
mailing list