{ size : ( Basics.Int
, Basics.Int )
, arrays : Array (Array a)
}
Stores elements in a rectangular 2-dimensional grid. Uses arrays internally.
empty : Matrix a
Create an empty matrix.
initialize : ( Basics.Int, Basics.Int ) -> (( Basics.Int, Basics.Int ) -> a) -> Matrix a
Create a matrix of a given size, with the element at index (x,y)
initialized to the result of f (x,y)
.
repeat : ( Basics.Int, Basics.Int ) -> a -> Matrix a
Create a matrix of a given size, filled with a default element.
fromList : List (List a) -> Matrix a
Create an array from a list of lists. The height will be either 0 or the length of the outer list. The width will be as wide as possible while keeping the matrix rectangular. If the width is 0, then the height is also 0, and vice-versa.
isEmpty : Matrix a -> Basics.Bool
Determine if a matrix is empty.
size : Matrix a -> ( Basics.Int, Basics.Int )
Return the dimensions of a matrix.
get : ( Basics.Int, Basics.Int ) -> Matrix a -> Maybe a
Return Just
the element at the index or Nothing
if the index is out of bounds.
set : ( Basics.Int, Basics.Int ) -> a -> Matrix a -> Matrix a
Set the element at a particular index. Returns an updated matrix. If the index is out of bounds, the matrix is unaltered.
slice : ( Basics.Int, Basics.Int ) -> ( Basics.Int, Basics.Int ) -> Matrix a -> Matrix a
Get a sub-section of a matrix: slice startIndex endIndex array
. The slice extracts from startIndex
up to but not including endIndex
.
toList : Matrix a -> List (List a)
Create a list of lists of elements from a matrix.
toIndexedList : Matrix a -> List ( ( Basics.Int, Basics.Int ), a )
Create a list of indexed elements from a matrix. Each element of the matrix will be paired with its index.
map : (a -> b) -> Matrix a -> Matrix b
Apply a function to every element in a matrix.
indexedMap : (( Basics.Int, Basics.Int ) -> a -> b) -> Matrix a -> Matrix b
Apply a function to every element in a matrix with its index as the first argument.