Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides pull arrays.
These are part of a larger framework for controlling when memory is
allocated for an array. See Data.Array.Polarized
.
Synopsis
- data Array a
- fromFunction :: (Int -> a) -> Int -> Array a
- fromVector :: Vector a %1 -> Array a
- make :: a -> Int -> Array a
- singleton :: a %1 -> Array a
- toVector :: Array a %1 -> Vector a
- asList :: Array a %1 -> [a]
- zip :: Array a %1 -> Array b %1 -> Array (a, b)
- zipWith :: (a %1 -> b %1 -> c) -> Array a %1 -> Array b %1 -> Array c
- append :: Array a %1 -> Array a %1 -> Array a
- foldr :: (a %1 -> b %1 -> b) -> b %1 -> Array a %1 -> b
- foldMap :: Monoid m => (a %1 -> m) -> Array a %1 -> m
- findLength :: Array a %1 -> (Int, Array a)
- split :: Int -> Array a %1 -> (Array a, Array a)
- reverse :: Array a %1 -> Array a
- index :: Array a %1 -> Int -> (a, Array a)
Documentation
A pull array is an array from which it is easy to extract elements, and this can be done in any order. The linear consumption of a pull array means each element is consumed exactly once, but the length can be accessed freely.
Construction
fromFunction :: (Int -> a) -> Int -> Array a Source #
constructs a pull array given a function
fromFunction
arrIndexer lenarrIndexer
that goes from an array index to array values and a specified
length len
.
fromVector :: Vector a %1 -> Array a Source #
Convert a Vector to a pull array.
make :: a -> Int -> Array a Source #
Creates a pull array of given size, filled with the given element.
singleton :: a %1 -> Array a Source #
Produce a pull array of lenght 1 consisting of solely the given element.
Consumption
Operations
zip :: Array a %1 -> Array b %1 -> Array (a, b) Source #
zip [x1, ..., xn] [y1, ..., yn] = [(x1,y1), ..., (xn,yn)]
Partial: `zip [x1,x2,...,xn] [y1,y2,...,yp]` is an error if n ≠ p
.
zipWith :: (a %1 -> b %1 -> c) -> Array a %1 -> Array b %1 -> Array c Source #
zipWith f [x1,x2,...,xn] [y1,y2,...,yn] = [f x1 y1, ..., f xn yn]
Partial: `zipWith f [x1,x2,...,xn] [y1,y2,...,yp]` is an error
if n ≠ p
.
findLength :: Array a %1 -> (Int, Array a) Source #
Extract the length of an array, and give back the original array.