Liking cljdoc? Tell your friends :D

had-utils.collections


all-2d-offsetsclj

Rectilinear and diagonal offsets in 2d

Rectilinear and diagonal offsets in 2d
sourceraw docstring

borderclj

(border grid i)

grid should be a rectangular collection of collections. Adds i as a border around the supplied grid.

`grid` should be a rectangular collection of collections. Adds `i`
as a border around the supplied grid.
sourceraw docstring

border-and-flattenclj

(border-and-flatten grid i)

Borders grid with i and then makes it into a one dimensional vector

Borders `grid` with `i` and then makes it into a
one dimensional vector
sourceraw docstring

bordervclj

(borderv grid i)

grid should be a rectangular collection of collections. Adds i as a border around grid. Return a vector of vectors

`grid` should be a rectangular collection of collections. Adds `i`
as a border around `grid`. Return a vector of vectors
sourceraw docstring

bracketclj

(bracket coll i)

Add the element i to the start and end of coll.

Add the element `i` to the start and end of `coll`.
sourceraw docstring

bracketvclj

(bracketv coll i)

Add the element i to the start and end of coll and return a vector.

Add the element `i` to the start and end of `coll` and return a vector.
sourceraw docstring

count-byclj

(count-by f coll)

Return a map from the distinct values of f applied to coll to the frequencies they occur.

Return a map from the distinct values of `f` applied to `coll`
to the frequencies they occur.
sourceraw docstring

count-whenclj

(count-when coll)
(count-when coll f)

Count the number of elements in coll where f returns true. If not supplied use identity as f.

Count the number of elements in `coll` where `f` returns true.
If not supplied use identity as `f`.
sourceraw docstring

diagonal-2d-offsetsclj

Diagonal offsets in 2d.

Diagonal offsets in 2d.
sourceraw docstring

filter-firstclj

(filter-first pred coll)

Find the first element in coll for which pred returns true

Find the first element in `coll` for which `pred` returns true
sourceraw docstring

grid-to-graphclj

(grid-to-graph grid edge-fn & {:keys [:with-diagonal :directed]})

Makes an ubergraph graph from the grid and edge-fn. If directed is true it is a directed graph. For each location [row col] we call edge-fn with the grid, the location, and each neighbor of the location (including diagonal neighbors if :with-diagonal is true). If edge-fn is true an edge is created from location to neighbor. If it is a number then that is assigned as the weight of the edge. Note that for undirected graphs edge-fn should be symmetrical in the location and neighbor location or there may be unexpected behavior, as it will be called twice.

Makes an ubergraph graph from the grid and edge-fn. If directed is true it is a directed graph.
For each location [row col] we call edge-fn with the grid, the location, and each neighbor of the
location (including diagonal neighbors if :with-diagonal is true). If edge-fn is true an edge is
created from location to neighbor. If it is a number then that is assigned as the weight of the edge.
Note that for undirected graphs edge-fn should be symmetrical in the location and neighbor location
or there may be unexpected behavior, as it will be called twice.
sourceraw docstring

in-grid-predclj

(in-grid-pred grid)

Returns a predicate on row and col or [row col] that says if that row and column are in the grid.

Returns a predicate on row and col or [row col] that says if
that row and column are in the grid.
sourceraw docstring

in-grid?clj

(in-grid? grid [row col])
(in-grid? grid row col)

Is the given row and column in the grid?

Is the given row and column in the grid?
sourceraw docstring

map-kvclj

(map-kv val-fn coll)
(map-kv key-fn val-fn coll)

Construct a new map from an existing one. Each of val-fn and key-fn (optional - default (fn [k _] k)) are a function of two arguments, the key and value. Note that to make the usage more natural the optional key-fn is the first argument when used.

Construct a new map from an existing one.
Each of `val-fn` and `key-fn` (optional - default `(fn [k _] k))` are
a function of two arguments, the key and value.
Note that to make the usage more natural the optional `key-fn`
is the first argument when used.
sourceraw docstring

neighbors-2dclj

(neighbors-2d grid loc & {:keys [:with-diagonal]})

loc is a [row col] coordinate in a 2d grid grid. Gives a vector of coordinates of horizontal and vertical neighbors, and also diagonal ones if :with-diagonal is true. Does not give neighbors that exceed the bounds of the grid.

`loc` is a [row col] coordinate in a 2d grid `grid`. Gives a vector of coordinates of horizontal
and vertical neighbors, and also diagonal ones if `:with-diagonal` is true. Does not give neighbors
that exceed the bounds of the grid.
sourceraw docstring

neighbors-2d-mapclj

(neighbors-2d-map grid loc & {:keys [:with-diagonal]})

loc is a [row col] coordinate in a 2d grid grid. Gives a map of coordinates of horizontal and vertical neighbors, and also diagonal ones if :with-diagonal is true, to their values in the grid. Does not give neighbors that exceed the bounds of the grid.

`loc` is a [row col] coordinate in a 2d grid `grid`. Gives a map of coordinates of horizontal
and vertical neighbors, and also diagonal ones if `:with-diagonal` is true, to their values in the grid.
Does not give neighbors that exceed the bounds of the grid.
sourceraw docstring

neighbors-2d-valsclj

(neighbors-2d-vals grid loc & {:keys [:with-diagonal]})

loc is a [row col] coordinate in a 2d grid grid. Gives a seq of values of horizontal and vertical neighbors, and also diagonal ones if :with-diagonal is true, to their values in the grid. Does not give neighbors that exceed the bounds of the grid.

`loc` is a [row col] coordinate in a 2d grid `grid`. Gives a seq of values of horizontal
and vertical neighbors, and also diagonal ones if `:with-diagonal` is true, to their values in the grid.
Does not give neighbors that exceed the bounds of the grid.
sourceraw docstring

pairsclj

(pairs seq)

Given seq (x0 x1 ... xn) returns a sequence of pairs ((x0 x1) (x0 x2) ... (x0 xn) (x1 x2) ...)

Given `seq` (x0 x1 ... xn) returns a sequence of pairs
((x0 x1) (x0 x2) ... (x0 xn) (x1 x2) ...)
sourceraw docstring

straight-2d-offsetsclj

Rectilinear offsets in 2d.

Rectilinear offsets in 2d.
sourceraw docstring

transposeclj

(transpose seqs)

Transpose a rectangular sequence of sequences.

Transpose a rectangular sequence of sequences.
sourceraw docstring

transposevclj

(transposev seqs)

Transpose a rectangular sequence of sequences, returning a vector of vectors.

Transpose a rectangular sequence of sequences,
returning a vector of vectors.
sourceraw docstring

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

× close