Re: Regarding writefln formatting

2012-03-22 Thread Kenji Hara
On Wednesday, 21 March 2012 at 01:26:23 UTC, bearophile wrote: import std.stdio; void main() { auto mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; writefln("%(%(%d %)\n%)", mat); writeln(); writefln("[%(%(%d %)\n%)]", mat); writeln(); w

Re: Regarding writefln formatting

2012-03-20 Thread bearophile
Andrej Mitrovic: I didn't know that! Is this documented anywhere? It's documented formally, but I see no usage examples of the nested formatting syntax: http://dlang.org/phobos/std_format.html Bye, bearophile

Re: Regarding writefln formatting

2012-03-20 Thread Andrej Mitrovic
On 3/21/12, bearophile wrote: > The following is just a note. The formatting syntax for arrays is > rather powerful, it allows you to pretty print a matrix. I didn't know that! Is this documented anywhere?

Re: Regarding writefln formatting

2012-03-20 Thread bearophile
import std.stdio; void main() { auto mat = [[1, 2, 3], [4, 15, 6], [7, 8, 9]]; writefln("[%([%(%2d, %)],\n %)]]", mat); } That outputs: [[ 1, 2, 3], [ 4, 15, 6], [ 7, 8, 9]] Sorry, the dlang forum online interface has added an extra leadin

Regarding writefln formatting

2012-03-20 Thread bearophile
This code: import std.stdio; void main() { auto mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; writefln("%(%(%d %)\n%)", mat); writeln(); writefln("[%(%(%d %)\n%)]", mat); writeln(); writefln("[%([%(%d %)]\n%)]", mat); writeln();