keen/col/mut-grid

Source
mut-grid[t] record
width nat64
height nat64

Mutable grid (matrix) type. This is intended for data that happens to fall in a grid; it may not be ideal for linear algebra.

This is row-major, meaning rows are stored contiguously. So, iteration functions typically start with the top row left-to-right, then the second row left-to-right, etc.

Grid elements are mutable, but changing the width or height is not supported.

new[t] t mut-grid()
New empty grid with width and height 0.
size[t] nat64(a t mut-grid)
Number of elements in the grid (width * height).
coord record
Coordinate in a grid.
new coord()
== bool(a coord, b coord)
show string(a coord)
has-coord[t] bool(a t mut-grid, coord coord)
true if coord is a valid coordinate (within the width and height of the grid).
row[t] t buffer-view(a t mut-grid, y nat64)
Returns the entire yth row. This is O(1). Throws index-too-big if y is out of range.
make[t] t mut-grid(width nat64, height nat64, f t mut((nat64, nat64)))
Creates a new grid, setting every element to f[x, y].
copy[t] t mut-grid(a t mut-grid)
Copy elements to a new grid.
subscript[t] t(a t mut-grid, coord coord)
set-subscript[t] void(a t mut-grid, coord coord, value t)
show[t] string(a t mut-grid) t show

Returns a string with one line for each row. Each row will have a space in between columns.

This makes no attempt to add padding to ensure columns line up.

mut-grid-rows[t] record (has private fields)
rows[t] t mut-grid-rows(a t mut-grid)
size[t] nat64(a t mut-grid-rows)
some[t] bool(a t mut-grid-rows, f bool mut(t buffer-view))
some[t] bool(a t mut-grid, f bool mut(t))
with-coords[t] record
inner t mut-grid
size[t] nat64(a t with-coords)
some[t] bool(a t with-coords, f bool mut((coord, t)))