Deciding one member of iteration chain at runtime

Chris Piker chris at hoopjump.com
Fri Feb 17 18:17:52 UTC 2023


On Friday, 17 February 2023 at 17:42:19 UTC, Ali Çehreli wrote:
>     // Two different steps
>     auto g1 = r.map!((int n) => n * n);
>     auto g2 = r.map!((int n) => n * 10);
>
>     // The rest of the algoritm
>     auto result = choose(condition, g1, g2)
>                   .array;

Now that's a handy construct.

There's many little goodies in phobos I've yet to learn, thanks 
for the tip!




More information about the Digitalmars-d-learn mailing list