table rotate left, table rotate right
These functions rotate the entire table contents to the left (counterclockwise) respecitvely to the right (clockwise). A rectangular table is assumed to be rotated with the maximum row width (i.e. the row with largest number of columns). The header row will be rotated as well as any other contents.
Indirect parameter passing is disabled
1-2
No. | Type | Description |
---|---|---|
1. input |
string | Name of existing table If only the 1st function parameter is provided, then this table will be rotated. If another table is named in the 2nd function parameter, then this table remains unchanged. |
Opt. 2. input |
string | Name of new table |
table initialize( t, { { 1, 2, 3 }, { 4, 5, 6, 6.1, 6.2 }, { 7, 8, 9 }, { 10, 11, 12 } } );
echo("Original table:");
table list(t);
table rotate left(t, l);
echo("Rotated counterclockwise:");
table list(l);
table rotate right(t);
echo("Orig. table rotated clockwise:");
table list(t);
Original table:
0 : 1 | 2 | 3 | |
1 : 4 | 5 | 6 | 6.1 | 6.2
2 : 7 | 8 | 9 | |
3 : 10 | 11 | 12 | |
Rotated counterclockwise:
0 : | 6.2 | |
1 : | 6.1 | |
2 : 3 | 6 | 9 | 12
3 : 2 | 5 | 8 | 11
4 : 1 | 4 | 7 | 10
Orig. table rotated clockwise:
0 : 10 | 7 | 4 | 1
1 : 11 | 8 | 5 | 2
2 : 12 | 9 | 6 | 3
3 : | | 6.1 |
4 : | | 6.2 |