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

bg-perimeterclj

(bg-perimeter boundary-graph)

For a grid boundary graph boundary-graph for a connected region in a grid-graph the perimeter of that region

For a grid boundary graph `boundary-graph` for a connected region in a grid-graph
the perimeter of that region
sourceraw docstring

bg-side-countclj

(bg-side-count boundary-graph)

For a grid boundary graph boundary-graph for a connected region in a grid-graph the number of sides that regions has.

For a grid boundary graph `boundary-graph` for a connected region in a grid-graph
the number of sides that regions has.
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)
(borderv grid i n)

grid should be a rectangular collection of collections. Adds i as a border around grid. If n >= 1 is supplied do this n times. Return a vector of vectors

`grid` should be a rectangular collection of collections. Adds `i`
as a border around `grid`. If `n` >= 1 is supplied do this n times.
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

coordinate-segmentclj

(coordinate-segment grid length point direction)

Get coordinates in the grid starting at point going in direction, including the point. length defines the maximum length returned. If the grid is exited then only return points in the grid, even if that is shorter than length.

Get coordinates in the grid starting at `point` going in `direction`,
including the `point`. `length` defines the maximum length returned.
If the grid is exited then only return points in the grid, even if
that is shorter than `length`.
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 f coll)

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. nil if none are found.

Find the first element in `coll` for which `pred` returns true.
nil if none are found.
sourceraw docstring

filter-grid-coordinatesclj

(filter-grid-coordinates f grid)
(filter-grid-coordinates f grid padding)
(filter-grid-coordinates f grid row-padding col-padding)

All indexes of the 2-d grid as [row col] vecs where the value satisfies the predicate f. If padding is supplied then omit that many rows and cols around the edges. If col-padding and row-padding are supplied then omit respectively for rows and cols.

All indexes of the 2-d `grid` as [row col] vecs where the value satisfies the
predicate `f`. If `padding` is supplied then
omit that many rows and cols around the edges. If `col-padding` and `row-padding` are
supplied then omit respectively for rows and cols.
sourceraw docstring

filter-in-gridclj

(filter-in-grid grid points)

Return only those points in the grid

Return only those points in the grid
sourceraw docstring

find-first-in-gridclj

(find-first-in-grid grid val)

Find the first coordinate in grid where the value is val.

Find the first coordinate in `grid` where the value is `val.`
sourceraw docstring

find-in-gridclj

(find-in-grid grid val)

Find all coordinates in grid where the value is val

Find all coordinates in `grid` where the value is `val`
sourceraw docstring

gg-component-boundary-pointsclj

(gg-component-boundary-points grid-graph component)

For grid-graph a set of 'boundary points' for the connected component component.

For `grid-graph` a set of 'boundary points' for the connected component
`component`.
sourceraw docstring

gg-make-boundary-graphclj

(gg-make-boundary-graph grid-graph component)

For grid-graph a 'boundary graph' for the connected component component that has boundary nodes as constructed by gg-component-boundary-points and edges between adjacent points on each side of the connected component's region as viewed in the original grid.

For `grid-graph` a 'boundary graph' for the connected component `component`
that has boundary nodes as constructed by `gg-component-boundary-points` and
edges between adjacent points on each side of the connected component's region
as viewed in the original grid.
sourceraw docstring

gg-node-boundary-pointsclj

(gg-node-boundary-points grid-graph node)
(gg-node-boundary-points grid-graph node d)

For grid-graph a set of 'boundary points' to node

  • these are points displaced off of node a distance d in the directions where node does not have a neighbor in the graph. In order to get the right boundary we do not restrict to neighbors in the grid!
For `grid-graph` a set of 'boundary points' to `node`
- these are points displaced off of `node` a distance `d` in
the directions where `node` does not have a neighbor in the graph.
In order to get the right boundary we do _not_ restrict to
neighbors in the grid!
sourceraw docstring

gg-unconnected-neighborsclj

(gg-unconnected-neighbors grid-graph node)

For grid-graph a set of rectilinear neighbors of node in the grid not connected to node by an edge.

For `grid-graph` a set of rectilinear neighbors of `node` in the grid
not connected to node by an edge.
sourceraw docstring

grid-centered-segmentclj

(grid-centered-segment grid length point direction)
(grid-centered-segment grid length point direction f)

In grid from point get length entries on either side (and point) starting at point + length - direction and going to point + length * (direction). Result returned as a vector. If f is supplied then call f on the vector. Only do coordinates in the grid. E.g. if the grid is [[1 2 3] [4 5 6] [7 8 9]] then (grid-centered-segment grid 1 [1 1] [1 0]) returns [2 5 8]

In `grid` from `point` get `length` entries on either side (and point) starting at
point + length - direction and going to point + length * (direction).
Result returned as a vector. If `f` is supplied then call f on the vector. Only do coordinates
in the grid.
E.g. if the grid is [[1 2 3] [4 5 6] [7 8 9]] then (grid-centered-segment grid 1 [1 1] [1 0])
returns [2 5 8]
sourceraw docstring

grid-coordinatesclj

(grid-coordinates grid)
(grid-coordinates grid padding)
(grid-coordinates grid row-padding col-padding)

All indexes of the 2-d grid as [row col] vecs. If padding is supplied then omit that many rows and cols around the edges. If col-padding and row-padding are supplied then omit respectively for rows and cols.

All indexes of the 2-d `grid` as [row col] vecs. If `padding` is supplied then
omit that many rows and cols around the edges. If `col-padding` and `row-padding` are
supplied then omit respectively for rows and cols.
sourceraw docstring

grid-flat-mapclj

(grid-flat-map f grid)
(grid-flat-map f grid padding)
(grid-flat-map f grid row-padding col-padding)

Map f, a function of the grid and point in the grid, over grid and resulting in a flat sequence, so the structure of the grid is lost. If padding, row-padding, col-padding are used then restrict the coordinates as in `grid-coordinates.

Map `f`, a function of the grid and point in the grid, over `grid` and resulting in a flat sequence, so
the structure of the grid is lost.
If `padding`, `row-padding`, `col-padding` are used then restrict the coordinates as in `grid-coordinates.
sourceraw docstring

grid-has-value?clj

(grid-has-value? grid val point)

Return whether the grid has value val at point point.

Return whether the `grid` has value `val` at point `point`.
sourceraw docstring

grid-mapclj

(grid-map f grid)
(grid-map f grid padding)
(grid-map f grid row-padding col-padding)

Map f, a function of the grid and point in the grid, over grid and resulting in a new grid. If padding, row-padding, col-padding are used then restrict the coordinates as in grid-coordinates, so the new grid will be smaller if there is padding

Map `f`, a function of the grid and point in the grid, over `grid` and resulting in a new grid.
If `padding`, `row-padding`, `col-padding` are used then restrict the coordinates as in `grid-coordinates`, so
the new grid will be smaller if there is padding
sourceraw docstring

grid-mapcatclj

(grid-mapcat f grid)
(grid-mapcat f grid padding)
(grid-mapcat f grid row-padding col-padding)

Map f, a function of the grid and point in the grid and returning a collection, over grid and concatenate the results. If padding, row-padding, col-padding are used then restrict the coordinates as in grid-coordinates.

Map `f`, a function of the grid and point in the grid and returning a collection,
over `grid` and concatenate the results.
If `padding`, `row-padding`, `col-padding` are used then restrict the coordinates
as in `grid-coordinates`.
sourceraw docstring

grid-segmentclj

(grid-segment grid length point direction)
(grid-segment grid length point direction f)

In grid get length entries going in direction [dx dy] starting at point [row col] as a vector. If f is supplied then call f on the vector instead. Only use coordinates in the grid.

In `grid` get `length` entries going in `direction` [dx dy]
starting at `point` [row col] as a vector. If `f` is supplied
then call f on the vector instead. Only use coordinates in the grid.
sourceraw docstring

grid-simple-mapclj

(grid-simple-map f grid)

A convenience to map f over grid, returning a vector of vectors

A convenience to map `f` over `grid`, returning a vector of vectors
sourceraw docstring

grid-to-graphclj

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

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. If :all-nodes is true than add nodes even if they don't have any edges.

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. If :all-nodes is true than add nodes
even if they don't have any edges.
sourceraw docstring

grid-valueclj

(grid-value grid point)

Return the value of the grid at point

Return the value of the `grid` at `point`
sourceraw docstring

grid=clj

(grid= grid p1 p2)
(grid= grid p1 p2 f)

true iff the value in the grid at p1 equals that at p2. If f is supplied then compare the value of f evaluated on the values at the points instead of the values at the points themselves.

true iff the value in the `grid` at `p1` equals that at `p2`.
If `f` is supplied then compare the value of `f` evaluated on the
values at the points instead of the values at the points themselves.
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

not-grid-has-value?clj

(not-grid-has-value? grid val point)

Return whether the grid does not have value val at point point

Return whether the `grid` does not have value `val` at point `point`
sourceraw docstring

pairsclj

(pairs seq)
(pairs seq pred)

Given seq (x0 x1 ... xn) returns a sequence of pairs ((x0 x1) (x0 x2) ... (x0 xn) (x1 x2) ...). If pred, a function of two variables, is provided then filter the pairs with that predicate.

Given `seq` (x0 x1 ... xn) returns a sequence of pairs
((x0 x1) (x0 x2) ... (x0 xn) (x1 x2) ...). If `pred`, a
function of two variables, is  provided then filter the pairs with that predicate.
sourceraw docstring

straight-2d-offsetsclj

Rectilinear offsets in 2d.

Rectilinear offsets in 2d.
sourceraw docstring

subgridclj

(subgrid grid row-start row-end col-start col-end)

Get a subgrid of the given grid with the normal start/end conventions. Returns a vector of vectors.

Get a subgrid of the given grid with the normal start/end conventions.
Returns a vector of vectors.
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