table flip horizontally / vertically

Prev Next

Function Names

table flip horizontally, table flip vertically

Description

These functions flip the entire table contents horizontally respectively vertically. A rectangular table is assumed to be rotated with the maximum row width (i.e. the row with largest number of columns). The entire header row will be treated like all other contents, i.e. flipped.

In case you want to flip selected rows or a specific range of columns, please refer to table flip rows() and table flip columns().

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

1-2

Parameters

No.TypeDescription
1.
input
string Name of existing table

If only the 1st function parameter is provided, then this table will be flipped. If another table is named in the 2nd function parameter, then this table remains unchanged.

Opt. 2.
input
string Name of new table

Examples

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 flip vertically(t, v);
echo("Flipped vertically:");
table list(v);

table flip horizontally(t);
echo("Orig. table flipped horizontally:");
table list(t);

Output

Original table:
    0 : 1  | 2  | 3  |     |    
    1 : 4  | 5  | 6  | 6.1 | 6.2
    2 : 7  | 8  | 9  |     |    
    3 : 10 | 11 | 12 |     |    

Flipped vertically:
    0 : 10 | 11 | 12 |     |    
    1 : 7  | 8  | 9  |     |    
    2 : 4  | 5  | 6  | 6.1 | 6.2
    3 : 1  | 2  | 3  |     |    

Orig. table flipped horizontally:
    0 :     |     | 3  | 2  | 1
    1 : 6.2 | 6.1 | 6  | 5  | 4
    2 :     |     | 9  | 8  | 7
    3 :     |     | 12 | 11 | 10

Try it yourself: Open LIB_Function_table_flip_horizontally.b4p in B4P_Examples.zip. Decompress before use.

See also

table flip rows
table flip columns