flip
result = flip(A, dim=1)
Input: A, dim · Output: result
What it is
Reverses row order (flipud, dim=1) or column order (fliplr/mirror, dim=2) of A, a Str, Vec, Mat, or Image. On a Str every spelling reverses the character order; on a plain Vec (which has no row/column orientation) both directions just reverse element order. dim (only meaningful for flip) is an optional keyword-or-positional scalar, 1 or 2, defaulting to 1.
Overloads
A can be Str, Vec, Mat, or Image; dim can be string or scalar.
3 forms. Each carries its own inputs, outputs and worked example — pick the tab for the one you are calling.
| Code | Input | Output | Description |
result = flip(A, dim=1) | A StrA a Str.dim string (default 1)Every spelling (flip, flipud, fliplr, mirror) reverses character order the same way, regardless of dim — a string has no row/ column orientation to pick between. | result — | — |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
print(flip("hello")) # olleh
olleh
| Code | Input | Output | Description |
result = flip(A, dim=1) | A VecA a plain Vec, which likewise has no row/column orientation.dim scalar (default 1)Both directions just reverse element order, so dim makes no difference here either. | result — | — |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
print(flip([1, 2, 3])) # [3, 2, 1]
[3, 2, 1]
| Code | Input | Output | Description |
result = flip(A, dim=1) | A Mat or ImageA an r×c Mat (or Image).dim scalar (default 1)Here dim genuinely matters: 1 reverses row order (top-to-bottom), 2 reverses column order (left-to-right). | result — | — |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
M = [1, 2; 3, 4]
print(flip(M, 1)) # [3, 4; 1, 2] -- rows reversed
[3, 4; 1, 2]