Implementation of Arrays with Braun Trees. Conceptually, Braun trees are always infinite. Consequently, there is no test on emptiness.
| Exported names: |
Datatypes:
Array
Functions:
!
| //
| applyAt
| combine
| combineSimilar
| emptyDefaultArray
| emptyErrorArray
| listToDefaultArray
| listToErrorArray
| update
| Summary of exported functions: |
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
| Imported modules: |
| Exported datatypes: |
Constructors:
| Exported functions: |
:: Array a
Creates an empty array which generates errors for non-initialized indexes.
:: (Int -> a) -> Array a
Creates an empty array, call given function for non-initialized indexes.
Example call: (emptyDefaultArray default)
default
- function to call for each non-initialized index
:: Array a -> [(Int,a)] -> Array a
Inserts a list of entries into an array.
Example call: (array // modifications)
array
- array to modify
modifications
- list of new (indexes,entries)
If an index in the list was already initialized, the old value
will be overwritten. Likewise the last entry with a given index
will be contained in the result array.
:: Array a -> Int -> a -> Array a
Inserts a new entry into an array.
Example call: (update array idx val)
array
- array to modify
idx
- index of update
val
- value to update at index idx
Entries already initialized will be overwritten.
:: Array a -> Int -> (a -> a) -> Array a
Applies a function to an element.
Example call: (applyAt array idx fun)
array
- array to modify
idx
- index of update
fun
- function to apply on element at index idx
:: Array a -> Int -> a
Yields the value at a given position.
Example call: (a ! n)
a
- array to look up in
n
- index, where to look
:: (Int -> a) -> [a] -> Array a
Creates a default array from a list of entries.
Example call: (listToDefaultArray def xs)
def
- default funtion for non-initialized indexes
xs
- list of entries
:: [a] -> Array a
Creates an error array from a list of entries.
Example call: (listToErrorArray xs)
xs
- list of entries
:: (a -> b -> c) -> Array a -> Array b -> Array c
combine two arbitrary arrays
:: (a -> a -> a) -> Array a -> Array a -> Array a
the combination of two arrays with identical default function and a combinator which is neutral in the default can be implemented much more efficient