Modern C++ Lamentations
John Colvin
john.loughran.colvin at gmail.com
Sun Dec 30 12:27:24 UTC 2018
On Saturday, 29 December 2018 at 22:01:58 UTC, Steven
Schveighoffer wrote:
> On 12/29/18 4:29 AM, Walter Bright wrote:
>> http://aras-p.info/blog/2018/12/28/Modern-C-Lamentations/
>>
>> Time to show off your leet D skilz and see how good we can do
>> it in D!
>
> Ugh, ranges really aren't a good fit for emulating nested
> loops, unless you write a specialized one.
>
> I tried my best, but it kind of sucks:
>
> foreach(z, x, y;
> iota(size_t.max)
> .map!(a =>
> zip(StoppingPolicy.shortest, a.repeat, iota(1, a)))
> .joiner
> .map!(t =>
> zip(StoppingPolicy.shortest, t[0].repeat,
> t[1].repeat, iota(t[1], t[0])))
> .joiner
> .filter!(t => t[0]*t[0] == t[1]*t[1] + t[2]*t[2])
> .take(100))
> {
> writeln(x, " ", y, " ", z);
> }
Isn't "StoppingPolicy.shortest" the default?
More information about the Digitalmars-d
mailing list