function fliplr
fliplr(x:
number
| array
| matrix
):
number
| array
| matrix

Flip a matrix left to right.

Reverses the order of the columns in the input matrix, flipping it left to right.

Examples

Flip a 2D matrix left to right

import { assertEquals } from "jsr:@std/assert";

assertEquals(fliplr([[1, 4], [2, 5], [3, 6]]), [[4, 1], [5, 2], [6, 3]]);

Flip a 1D array (no change)

import { assertEquals } from "jsr:@std/assert";

assertEquals(fliplr([1, 2, 3]), [1, 2, 3]);

Parameters

x:
number
| array
| matrix

The input array or matrix.

Return Type

number
| array
| matrix

The matrix with its columns flipped left to right.

Throws

If no input is provided.

Usage

import fliplr from "matarrs/fliplr.ts";