Abstract
Functions on pure arrays.
This module contains modules and functions for manipulating arrays. Which might be something like deduplication or a generalized reduction by a key.
Synopsis
local module type array = {
| |||||||||||||||||
| module array | : | array | |||||||||||||||
module type array_key = {
| |||||||||||||||||
| module mk_array_key | : | (K: hashkey) -> (E: rng_engine with int.t = u64) -> array_key with rng = E.rng with key = K.key with ctx = K.ctx | |||||||||||||||
Description
- ↑module type array_key
A module type for functions on arrays of keys. Use
mk_array_keyto produce a module that implements this module type, given a random number generator.- ↑type key
The key type.
- ↑type ctx
The context type.
- ↑type rng
The random number generator.
- ↑val reduce_by_key [n] 'v: ctx -> rng -> (v -> v -> v) -> v -> [n](key, v) -> ?[m].(rng, [m](key, v))
Reduce by key works like Futharks
reduce_by_indexbut instead of the need to make every value correspond to an index in some array it can instead correspond to a key. Here an array ofnkeykand valuevpairs are given as an array. And every value with the same key will be reduced with an associative and commutative operatorop, futhermore an neutral elementnemust be given.- ↑val dedup [n]: ctx -> rng -> [n]key -> ?[m].(rng, [m]key)
Removes duplicate elements from an array as defined by the equality relation of the key. This implementation works much like
reduce_by_keybut saves some steps which makes it faster.
- ↑module mk_array_key