Liking cljdoc? Tell your friends :D

emlyn.grid

The Grid public API.

The Grid public API.
raw docstring

add-colsclj

(add-cols grid & {:keys [num pos] :or {num 1}})
source

add-rowsclj

(add-rows grid & {:keys [num pos] :or {num 1}})
source

colsclj

(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.
sourceraw docstring

concat-lrclj

(concat-lr grid & grids)
source

concat-tbclj

(concat-tb grid & grids)
source

drop-colsclj

(drop-cols grid & {:keys [num pos] :or {num 1}})
source

drop-rowsclj

(drop-rows grid & {:keys [num pos] :or {num 1}})
source

everywhereclj

(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))
```
sourceraw docstring

flip-lrclj

(flip-lr grid)

Flip a grid left to right.

Flip a grid left to right.
sourceraw docstring

flip-tbclj

(flip-tb grid)

Flip a grid top to bottom.

Flip a grid top to bottom.
sourceraw docstring

gridclj

(grid data)
(grid w h & [data])

Construct a grid.

Construct a grid.
sourceraw docstring

heightclj

(height grid)

The height of a grid in cells.

The height of a grid in cells.
sourceraw docstring

map-kvclj

(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.
sourceraw docstring

map-valsclj

(map-vals fn grid & grids)

Map a function over the values of a grid.

Map a function over the values of a grid.
sourceraw docstring

merge-print-opts!clj

(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.
sourceraw docstring

(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)
```
sourceraw docstring

rotate-180clj

(rotate-180 grid)

Rotate a grid 180 degrees.

Rotate a grid 180 degrees.
sourceraw docstring

rotate-leftclj

(rotate-left grid)

Rotate a grid 90 degrees anticlockwise.

Rotate a grid 90 degrees anticlockwise.
sourceraw docstring

rotate-rightclj

(rotate-right grid)

Rotate a grid 90 degrees clockwise.

Rotate a grid 90 degrees clockwise.
sourceraw docstring

rowsclj

(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.
sourceraw docstring

set-index-mode!clj

(set-index-mode! mode)

Permanently sets the default index mode. See with-index-mode

Permanently sets the default index mode. See `with-index-mode`
sourceraw docstring

table-strclj

(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.
sourceraw docstring

to-mapclj

(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))
```
sourceraw docstring

to-mapsclj

(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))
```
sourceraw docstring

to-vecclj

(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)
```
sourceraw docstring

to-vecsclj

(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)
```
sourceraw docstring

transposeclj

(transpose grid)

Transpose a grid (reflect it around the x=y line).

Transpose a grid (reflect it around the x=y line).
sourceraw docstring

widthclj

(width grid)

The width of a grid in cells.

The width of a grid in cells.
sourceraw docstring

with-index-modecljmacro

(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.
sourceraw docstring

with-print-optscljmacro

(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 "...")
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close