Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Array & table functions
Synopsis
- larray_bounds :: Ord k => [(k, v)] -> (k, k)
- larray :: Ix k => [(k, v)] -> Array k v
- type Table a = [[a]]
- tbl_rows :: Table t -> Int
- tbl_columns :: Table t -> Int
- tbl_is_regular :: Table t -> Bool
- tbl_make_regular :: (t -> u, u) -> Table t -> Table u
- tbl_make_regular_nil :: t -> Table t -> Table t
- type Dimensions i = (i, i)
- type Ix i = (i, i)
- ix_translate :: Num t => (t, t) -> Ix t -> Ix t
- ix_modulo :: Integral t => Dimensions t -> Ix t -> Ix t
- row_indices :: (Enum t, Num t) => t -> t -> [Ix t]
- column_indices_at :: (Enum t, Num t) => t -> t -> [Ix t]
- matrix_indices :: (Enum t, Num t) => Dimensions t -> [Ix t]
- matrix_corner_indices :: Num t => Dimensions t -> [Ix t]
- parallelogram_corner_indices :: Num t => (Dimensions t, t) -> [Ix t]
- all_ix_translations :: Integral t => Dimensions t -> [Ix t] -> [[Ix t]]
- all_ix_translations_uniq :: Integral t => Dimensions t -> [Ix t] -> [[Ix t]]
Association List (List Array)
larray_bounds :: Ord k => [(k, v)] -> (k, k) Source #
minmax
of k.
List Table
Plain list representation of a two-dimensional table of a in row-order. Tables are regular, ie. all rows have equal numbers of columns.
tbl_columns :: Table t -> Int Source #
Table column count, assumes table is regular.
tbl_is_regular :: Table t -> Bool Source #
Determine is table is regular, ie. all rows have the same number of columns.
tbl_is_regular [[0..3],[4..7],[8..11]] == True
tbl_make_regular :: (t -> u, u) -> Table t -> Table u Source #
Map f at table, padding short rows with k.
tbl_make_regular_nil :: t -> Table t -> Table t Source #
Append a sequence of nil (or default) values to each row of tbl so to make it regular (ie. all rows of equal length).
Matrix Indices
type Dimensions i = (i, i) Source #
Matrix dimensions are written (rows,columns).
ix_translate :: Num t => (t, t) -> Ix t -> Ix t Source #
Translate Ix
by row and column delta.
ix_translate (1,2) (3,4) == (4,6)
ix_modulo :: Integral t => Dimensions t -> Ix t -> Ix t Source #
Modulo Ix
by Dimensions
.
ix_modulo (4,4) (3,7) == (3,3)
row_indices :: (Enum t, Num t) => t -> t -> [Ix t] Source #
Given number of columns and row index, list row indices.
row_indices 3 1 == [(1,0),(1,1),(1,2)]
column_indices_at :: (Enum t, Num t) => t -> t -> [Ix t] Source #
Given number of rows and column index, list column indices.
column_indices_at 3 1 == [(0,1),(1,1),(2,1)]
matrix_indices :: (Enum t, Num t) => Dimensions t -> [Ix t] Source #
All zero-indexed matrix indices, in row order. This is the order
given by sort
.
matrix_indices (2,3) == [(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)] sort (matrix_indices (2,3)) == matrix_indices (2,3)
matrix_corner_indices :: Num t => Dimensions t -> [Ix t] Source #
Corner indices of given Dimensions
, in row order.
matrix_corner_indices (2,3) == [(0,0),(0,2),(1,0),(1,2)]
parallelogram_corner_indices :: Num t => (Dimensions t, t) -> [Ix t] Source #
Parallelogram corner indices, given as rectangular Dimensions
with an
offset for the lower indices.
parallelogram_corner_indices ((2,3),2) == [(0,0),(0,2),(1,2),(1,4)]
all_ix_translations :: Integral t => Dimensions t -> [Ix t] -> [[Ix t]] Source #
Apply ix_modulo
and ix_translate
for all matrix_indices
,
ie. all translations of a shape
in row order. The resulting Ix
sets are not sorted and may have duplicates.
concat (all_ix_translations (2,3) [(0,0)]) == matrix_indices (2,3)
all_ix_translations_uniq :: Integral t => Dimensions t -> [Ix t] -> [[Ix t]] Source #
Sort sets into row order and remove duplicates.