The CellGrid package provides a type for representing a rectangular grid of cells. CellGrids can be created, transformed, and rendered as either SVG or HTML.
A cell can be in the interior of the grid, on an edge, on in a cornder
Construct a Maybe CellGrid from a list of values of type a.
Here is a 2x2 cell grid of type Float:
> cg = fromList 2 2 [1.0,2.0,3.0,4.0]
Just (CellGrid (2,2) (Array.fromList [1,2,3,4]))
: Maybe (CellGrid Float)If the length of the list is incompatible with the
given number of rows and columns Nothing is returned.
> fromList 2 2 [1.0,2.0,3.0,4.0, 5.0]
Nothing : Maybe (CellGrid Float)Map a function over a CellGrid:
> map (\x -> 2*x) cg
CellGrid (2,2) (Array.fromList [2,4,6,8])Transform a CellGrid a with a function ((Int, Int) -> a -> a). Used when the transformed value depends on its matrixIndex as well as its value
Transform a CellGrid using a function
(Int, Int) -> CellGrid a -> a)return the type of the cell at location (i,j). Thus classifyCell grid (0,0) = Corner
Return the Maybe value of the cell at (i,j) from grid
> cellAtMatrixIndex (1,1) cg
Just 4 : Maybe FloatConversely, (nRows, nCols) k is the
2D array index (i,j) of the element al index k
Return a list of all matrix indices (i,j) of a grid. Useful for mapping.
Make a CellGrid Float using a temperatureMap. The latter assigns a Float to an integer tuple (row, col)
A value of type
CellGrid ais a rectangular array of values of type a.