Rotate array in writefln?

Stefan Koch uplink.coder at googlemail.com
Wed Apr 18 07:07:34 UTC 2018


On Wednesday, 18 April 2018 at 06:54:29 UTC, Chris Katko wrote:
> I need to rotate an array by 90 degrees, or have writefln 
> figure that out.
>
> I need, say:
>
> 0 4 5 6
> 0 0 0 0
> 0 0 0 0
> 0 0 0 0
>
> But it's outputting:
>
> 0 0 0 0
> 4 0 0 0
> 5 0 0 0
> 6 0 0 0
>
> int [4][4] data;
> file.writeln(format("%(%-(%d %)\n%)", data));

You can transpose the matrix :)


More information about the Digitalmars-d-learn mailing list