the best language I have ever met(?)

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Nov 18 13:28:44 PST 2016


On Friday, 18 November 2016 at 20:31:57 UTC, Igor Shirkalin wrote:
> After 2 hours of brain breaking (as D newbie) I have come to:
>
> <code D>
> uint_array.map!(v=>"%x".format(v)).join(", ")
> </code D>
> Why 2 hours? Because I have started with 'joiner' function and 
> aftewords found out the 'join'.
>
> To my mind there is more simple form for this task in D (about 
> formatting).

sure ;-)

import std.stdio;
import std.format;
void main () {
   uint[$] a = [42, 69];
   string s = "%(%s, %)".format(a);
   writefln(s);
}


More information about the Digitalmars-d-learn mailing list