subset(m: array): array
Extract a subset of an array or matrix based on row and column indices.
Extracts a subset from an array or matrix based on specified row and column indices. If the indices are not provided, the entire array or matrix is returned. Use ':' to select all rows or columns.
Extract a single element from an array
Extract a single element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, 1), 6);
Extract multiple elements from an array
Extract multiple elements from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, [1, 2]), [6, 3]);
Extract the last element from an array
Extract the last element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, c.length - 1), 3);
Extract a single element from a matrix
Extract a single element from a matrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, 0, 1), [[6]]);
Extract a submatrix
Extract a submatrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, [0, 1], [1, 2]), [[6, 5], [8, -1]]);
m: array
The input array or matrix.
The extracted subset of the array or matrix.
subset(m: matrix): matrix
Extract a subset of an array or matrix based on row and column indices.
Extracts a subset from an array or matrix based on specified row and column indices. If the indices are not provided, the entire array or matrix is returned. Use ':' to select all rows or columns.
Extract a single element from an array
Extract a single element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, 1), 6);
Extract multiple elements from an array
Extract multiple elements from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, [1, 2]), [6, 3]);
Extract the last element from an array
Extract the last element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, c.length - 1), 3);
Extract a single element from a matrix
Extract a single element from a matrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, 0, 1), [[6]]);
Extract a submatrix
Extract a submatrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, [0, 1], [1, 2]), [[6, 5], [8, -1]]);
m: matrix
The input array or matrix.
The extracted subset of the array or matrix.
subset(m: array,r: number,): number
Extract a subset of an array or matrix based on row and column indices.
Extracts a subset from an array or matrix based on specified row and column indices. If the indices are not provided, the entire array or matrix is returned. Use ':' to select all rows or columns.
Extract a single element from an array
Extract a single element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, 1), 6);
Extract multiple elements from an array
Extract multiple elements from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, [1, 2]), [6, 3]);
Extract the last element from an array
Extract the last element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, c.length - 1), 3);
Extract a single element from a matrix
Extract a single element from a matrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, 0, 1), [[6]]);
Extract a submatrix
Extract a submatrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, [0, 1], [1, 2]), [[6, 5], [8, -1]]);
m: array
The input array or matrix.
subset(): array
Extract a subset of an array or matrix based on row and column indices.
Extracts a subset from an array or matrix based on specified row and column indices. If the indices are not provided, the entire array or matrix is returned. Use ':' to select all rows or columns.
Extract a single element from an array
Extract a single element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, 1), 6);
Extract multiple elements from an array
Extract multiple elements from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, [1, 2]), [6, 3]);
Extract the last element from an array
Extract the last element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, c.length - 1), 3);
Extract a single element from a matrix
Extract a single element from a matrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, 0, 1), [[6]]);
Extract a submatrix
Extract a submatrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, [0, 1], [1, 2]), [[6, 5], [8, -1]]);
The extracted subset of the array or matrix.
subset(): array | matrix
Extract a subset of an array or matrix based on row and column indices.
Extracts a subset from an array or matrix based on specified row and column indices. If the indices are not provided, the entire array or matrix is returned. Use ':' to select all rows or columns.
Extract a single element from an array
Extract a single element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, 1), 6);
Extract multiple elements from an array
Extract multiple elements from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, [1, 2]), [6, 3]);
Extract the last element from an array
Extract the last element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, c.length - 1), 3);
Extract a single element from a matrix
Extract a single element from a matrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, 0, 1), [[6]]);
Extract a submatrix
Extract a submatrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, [0, 1], [1, 2]), [[6, 5], [8, -1]]);
subset():
Extract a subset of an array or matrix based on row and column indices.
Extracts a subset from an array or matrix based on specified row and column indices. If the indices are not provided, the entire array or matrix is returned. Use ':' to select all rows or columns.
Extract a single element from an array
Extract a single element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, 1), 6);
Extract multiple elements from an array
Extract multiple elements from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, [1, 2]), [6, 3]);
Extract the last element from an array
Extract the last element from an array
import { assertEquals } from "jsr:@std/assert"; const c = [5, 6, 3]; assertEquals(subset(c, c.length - 1), 3);
Extract a single element from a matrix
Extract a single element from a matrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, 0, 1), [[6]]);
Extract a submatrix
Extract a submatrix
import { assertEquals } from "jsr:@std/assert"; const a = [[5, 6, 5], [7, 8, -1]]; assertEquals(subset(a, [0, 1], [1, 2]), [[6, 5], [8, -1]]);