in reply to How to warp an array by trading X/Y coordinates (rows/columns)
Like this?:
#! perl -slw use strict; use Data::Dump qw[ pp ]; my @data = map[ split ' ' ], <DATA>; pp \@data; my @xformed; push @xformed, [ map shift @$_ // (), @data ] while @{ $data[ 0 ] }; pp \@xformed; __DATA__ 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16
Output:
C:\test>1157088.pl [[1, 5, 9, 13], [2, 6, 10, 14], [3, 7, 11, 15], [4, 8, 12, 16]] [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to warp an array by trading X/Y coordinates (rows/columns)
by Polyglot (Chaplain) on Mar 08, 2016 at 15:50 UTC | |
by BrowserUk (Patriarch) on Mar 08, 2016 at 15:56 UTC |