Safe Haskell | Safe-Inferred |
---|
Helpers for two-dimensional arrays.
- data Table lCol lRow col row a
- lCols :: Table lCol lRow col row a -> Array col lCol
- lRows :: Table lCol lRow col row a -> Array row lRow
- cells :: Table lCol lRow col row a -> Array (col, row) a
- table :: (Ix col, Ix row) => (col -> [(row, a)] -> lCol) -> (row -> [(col, a)] -> lRow) -> Array (col, row) a -> Table lCol lRow col row a
- labelCols :: (Ix col, Ix row) => (col -> [(row, a)] -> lCol) -> Array (col, row) a -> Array col lCol
- labelRows :: (Ix col, Ix row) => (row -> [(col, a)] -> lRow) -> Array (col, row) a -> Array row lRow
- mapTable :: (Ix col, Ix row) => (lCol -> lRow -> col -> row -> a -> b) -> Table lCol lRow col row a -> Table lCol lRow col row b
- mapColLabels :: (Ix col, Ix row) => (lCol -> col -> [(lRow, row, a)] -> lCol') -> Table lCol lRow col row a -> Table lCol' lRow col row a
- mapRowLabels :: (Ix col, Ix row) => (lRow -> row -> [(lCol, col, a)] -> lRow') -> Table lCol lRow col row a -> Table lCol lRow' col row a
- cols :: (Ix col, Ix row) => Array (col, row) a -> [[a]]
- rows :: (Ix col, Ix row) => Array (col, row) a -> [[a]]
- arrayByRows :: [[a]] -> Array (Int, Int) a
- arrayByCols :: [[a]] -> Array (Int, Int) a
Tables
data Table lCol lRow col row a Source
A Table is a two-dimensional array with two associated one-dimensional arrays: an array of labels for each column, and an array of labels for each row.
:: (Ix col, Ix row) | |
=> (col -> [(row, a)] -> lCol) | Function to generate the column labels. It is applied to the column index and the full contents of the column. |
-> (row -> [(col, a)] -> lRow) | Function to generate the row labels. It is applied to the row index and the full contents of the row. |
-> Array (col, row) a | Cells of the table |
-> Table lCol lRow col row a |
Make a new Table.
:: (Ix col, Ix row) | |
=> (col -> [(row, a)] -> lCol) | Function to generate the column labels. It is applied to the column index and the full contents of the column. |
-> Array (col, row) a | |
-> Array col lCol |
Given a two-dimensional array and a function that generates labels, return an array of column labels.
:: (Ix col, Ix row) | |
=> (row -> [(col, a)] -> lRow) | Function to generate the row labels. It is applied to the row index and the full contents of the row. |
-> Array (col, row) a | |
-> Array row lRow |
Given a two-dimensional array and a function that generates labels, return an array of row labels.
:: (Ix col, Ix row) | |
=> (lCol -> lRow -> col -> row -> a -> b) | Function is passed the label for the column, the label for the row, the column index, the row index, and the contents of the cell. It returns a new cell. |
-> Table lCol lRow col row a | |
-> Table lCol lRow col row b |
Transform the cells of the table. Similar to the Functor
instance, but the mapping function has access to the label and
index of each cell in the Table
.
:: (Ix col, Ix row) | |
=> (lCol -> col -> [(lRow, row, a)] -> lCol') | The function is passed the column label, column index, and the full contents of the column. |
-> Table lCol lRow col row a | |
-> Table lCol' lRow col row a |
Transform the column labels.
:: (Ix col, Ix row) | |
=> (lRow -> row -> [(lCol, col, a)] -> lRow') | The function is passed the row label, the row index, and the full contents of the row. |
-> Table lCol lRow col row a | |
-> Table lCol lRow' col row a |
Transform the row labels.
Two-dimensional arrays
cols :: (Ix col, Ix row) => Array (col, row) a -> [[a]]Source
Given a two-dimensional array, return a list of columns in order.
rows :: (Ix col, Ix row) => Array (col, row) a -> [[a]]Source
Given a two-dimensional array, return a list of rows in order.
arrayByRows :: [[a]] -> Array (Int, Int) aSource
Generate a two-dimensional array from a list of rows. Each row must be of equal length; otherwise, the generated array will have undefined elements.
arrayByCols :: [[a]] -> Array (Int, Int) aSource
Generate a two-dimensional array from a list of columns. Each column must be of equal length; otherwise, the generated array will have undefined elements.