To write such an expressive code D

Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 9 20:17:47 PST 2015


On Monday, 9 February 2015 at 20:16:45 UTC, Ali Çehreli wrote:
> Yes, but apparently D's default precision for output is less 
> than F#'s so how about the following? :p
>
>     "%(%.15g\n%)".writefln(iota(0, PI/2, PI/2/9).map!sin);
>
> Just for demonstration, I would not write anything like that 
> but the following is fine because now the format becomes the 
> second parameter: :)
>
>     iota(0, PI/2, PI/2/9).map!sin.writeF("%(%.15g\n%)");
>
> void writeF(R)(R range, string format)
> {
>     return writefln(format, range);
> }

Ali, and you can write it without using the function "iota()" and 
map?
"%(%.15g\n%)".writefln(iota(0, PI/2, PI/2/9).map!sin);

I just need that code was only used features of the language 
without using library functions. You may only use the function 
sin().


More information about the Digitalmars-d-learn mailing list