Modern C++ Lamentations

Walter Bright newshound2 at digitalmars.com
Sun Dec 30 22:32:23 UTC 2018


On 12/29/2018 6:03 PM, Timon Gehr wrote:
> Current D:
> ---
> import std.range, std.algorithm, std.typecons;
> import std.bigint, std.stdio;
> alias then(alias a)=(r)=>map!a(r).joiner;
> void main(){
>      auto triples=recurrence!"a[n-1]+1"(1.BigInt)
>          .then!(z=>iota(1,z+1).then!(x=>iota(x,z+1).map!(y=>tuple(x,y,z))))
>          .filter!((t)=>t[0]^^2+t[1]^^2==t[2]^^2);
>      triples.each!((x,y,z){ writeln(x," ",y," ",z); });
> }
> ---

I never would have thought of that. Thank you!




More information about the Digitalmars-d mailing list