the best language I have ever met(?)

Igor Shirkalin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 19 09:12:13 PST 2016


On Friday, 18 November 2016 at 21:28:44 UTC, ketmar wrote:
> 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);
> }

Accepted.
Is it really needed to call 'writefln'? I mean 'f'.


More information about the Digitalmars-d-learn mailing list