"fold": a replacement for "reduce"
bearophile
bearophileHUGS at lycos.com
Mon Mar 31 06:05:23 PDT 2014
monarch_dodra:
> So my vote goes to this solution.
>
> //----
> uint[] foo3(in uint[][] X)
> {
> assert(!X.empty)
> auto seed = X.front.dup;
> X.popFront();
> return reduce!((i, j) => zip(i, j)
> .map!(kw => kw[0] | kw[1])
> .array)
> (seed, X);
> }
> //----
>
> I re-wrote it that way: It's a bit longer, but a bit more
> generic in terms of customizing your seed.
OK, thank you. So the price for that "in" is to use a dup :-) (Or
use lower level code).
Bye,
bearophile
More information about the Digitalmars-d
mailing list