How to best translate this C++ algorithm into D?
logicchains via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jun 7 06:31:20 PDT 2014
On Saturday, 7 June 2014 at 13:25:07 UTC, Timon Gehr wrote:
> What about (untested)?:
>
> static forest_t[] possible_meals = [{-1, -1, +1}, {-1, +1, -1},
> {+1, -1, -1}];
> return forests.map!(a=>possible_meals.map!(b=>b+a))
> .join.partition!forest_invalid.sort.uniq.array;
>
> (Of course, this still allocates two arrays.)
That seems around 5% slower, for some reason.
More information about the Digitalmars-d
mailing list