@oazmi/kitchensink - v0.9.13
    Preparing search index...

    Function spliceArray2DMinor

    • splice columns of a row-major 2D array and optionally insert new columns at the specified start index.

      Type Parameters

      • T

      Parameters

      • arr2d: Array2DRowMajor<T>

        the row-major 2D array to be spliced.

      • start: number

        the column-index at which to start changing the array.

      • Optionaldelete_count: number

        the number of columns to remove. if undefined, all columns from start to the end of the array will be removed.

      • ...insert_items: Array2DColMajor<T>

        optionally insert column-major based 2D array items the index of start.

      Returns Array2DColMajor<T>

      a new column-major 2D array containing the deleted columns.

      delete 2 columns from arr2d (starting at column-index 1), and insert 5 new columns in its place.

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

      const arr2d: Array2DRowMajor<number> = [
      [1 , 2 , 3 , 4 , 5 ],
      [6 , 7 , 8 , 9 , 10],
      [11, 12, 13, 14, 15],
      ]
      const deleted_cols = spliceArray2DMinor(arr2d, 1, 2,
      [21, 31, 41],
      [22, 32, 42],
      [23, 33, 43],
      [24, 34, 44],
      [25, 35, 45]
      )
      assertEquals(arr2d, [
      [1 , 21, 22, 23, 24, 25, 4 , 5 ],
      [6 , 31, 32, 33, 34, 35, 9 , 10],
      [11, 41, 42, 43, 44, 45, 14, 15],
      ])
      assertEquals(deleted_cols, [
      [2 , 7 , 12],
      [3 , 8 , 13],
      ])