The Grid public API.
The Grid public API.
(cols grid)
A sequence of vectors containing the values in each column of the grid.
A sequence of vectors containing the values in each column of the grid.
(everywhere val)
Represents an unbounded grid with the same value everywhere. This is useful when initialising a new grid with a default value, or when setting all cells in an area of an existing grid to the same value.
(grid 4 4 (everywhere 0))
(assoc grid [[0 4] [0 2]] (everywhere 42))
Represents an unbounded grid with the same value everywhere. This is useful when initialising a new grid with a default value, or when setting all cells in an area of an existing grid to the same value. ``` (grid 4 4 (everywhere 0)) ``` ``` (assoc grid [[0 4] [0 2]] (everywhere 42)) ```
(height grid)
The height of a grid in cells.
The height of a grid in cells.
(map-kv fn grid & grids)
Map a function over the keys and values of a grid.
Map a function over the keys and values of a grid.
(map-vals fn grid & grids)
Map a function over the values of a grid.
Map a function over the values of a grid.
(merge-print-opts! & {:as opts})
Permanently merge the given options with the current print options.
Permanently merge the given options with the current print options.
(print-table grid & {:keys [writer] :or {writer *out*} :as opts})
Print a grid as a table.
(print-table grid :style :rounded)
Print a grid as a table. ``` (print-table grid :style :rounded) ```
(rotate-180 grid)
Rotate a grid 180 degrees.
Rotate a grid 180 degrees.
(rotate-left grid)
Rotate a grid 90 degrees anticlockwise.
Rotate a grid 90 degrees anticlockwise.
(rotate-right grid)
Rotate a grid 90 degrees clockwise.
Rotate a grid 90 degrees clockwise.
(rows grid)
A sequence of vectors containing the values in each row of the grid.
A sequence of vectors containing the values in each row of the grid.
(set-index-mode! mode)
Permanently sets the default index mode. See with-index-mode
Permanently sets the default index mode. See `with-index-mode`
(table-str grid & {:as opts})
Return a string containing a grid formatted as a table.
Return a string containing a grid formatted as a table.
(to-map grid & {:keys [filter] :or {filter some?}})
Convert a grid to a map of xy-coordinate to value optionally filtering out some cells (by default nils).
(to-map grid :filter #(not= % 0))
Convert a grid to a map of xy-coordinate to value optionally filtering out some cells (by default nils). ``` (to-map grid :filter #(not= % 0)) ```
(to-maps grid & {:keys [filter xy-order] :or {filter some?}})
Convert a grid to a map of y (or x) coordinate to map of x (or y) coordinate to value,
optionally filtering out some cells (by default nils).
By default uses y as the first coordinate to match the format used in the constructor,
pass in :xy-order true
to use x as the first coordinate.
(to-grids grid :xy-order true :filter (partial not= 0))
Convert a grid to a map of y (or x) coordinate to map of x (or y) coordinate to value, optionally filtering out some cells (by default nils). By default uses y as the first coordinate to match the format used in the constructor, pass in `:xy-order true` to use x as the first coordinate. ``` (to-grids grid :xy-order true :filter (partial not= 0)) ```
(to-vec grid)
Convert a grid to a flat vector of all values (left to right, top to bottom).
This is the same as calling vals
on the grid.
(to-vec grid)
Convert a grid to a flat vector of all values (left to right, top to bottom). This is the same as calling `vals` on the grid. ``` (to-vec grid) ```
(to-vecs grid)
Convert a grid to a vector of vectors, one for each row. Similar to calling [emlyn.grid/rows] on the grid.
(to-vecs grid)
Convert a grid to a vector of vectors, one for each row. Similar to calling [emlyn.grid/rows] on the grid. ``` (to-vecs grid) ```
(transpose grid)
Transpose a grid (reflect it around the x=y line).
Transpose a grid (reflect it around the x=y line).
(with-index-mode mode & body)
How to handle indices outside the usual bounds. Valid mode values are:
:strict
(default): no special handling of indices:wrap
: indices wrap around the edges of the grid:clamp
: indices clamp to the edges of the grid:python
: negative indices count from the end of the grid
Indices that still fall outside the grid after this handling will
throw an exception if you try to set (e.g. assoc
) them,
and will return the default value (or nil
) when you read them.How to handle indices outside the usual bounds. Valid mode values are: - `:strict` (default): no special handling of indices - `:wrap`: indices wrap around the edges of the grid - `:clamp`: indices clamp to the edges of the grid - `:python`: negative indices count from the end of the grid Indices that still fall outside the grid after this handling will throw an exception if you try to set (e.g. `assoc`) them, and will return the default value (or `nil`) when you read them.
(with-print-opts opts & body)
Temporarily set the default options for printing tables. Options are:
:style
- the style of table to print (default :markdown
):pad
- padding around each cell (default 1):align
- alignment of cell values, one of :left
, :right
, or :centre
(default :right
):truncate
- whether to truncate the table to a maximum number of rows and columns (default true):max-cols
- maximum number of columns in the table (default 8):max-rows
- maximum number of rows in the table (default 16):overflow-val
- value to use for cells that overflow the grid (default "...")Temporarily set the default options for printing tables. Options are: - `:style` - the style of table to print (default `:markdown`) - `:pad` - padding around each cell (default 1) - `:align` - alignment of cell values, one of `:left`, `:right`, or `:centre` (default `:right`) - `:truncate` - whether to truncate the table to a maximum number of rows and columns (default true) - `:max-cols` - maximum number of columns in the table (default 8) - `:max-rows` - maximum number of rows in the table (default 16) - `:overflow-val` - value to use for cells that overflow the grid (default "...")
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close