| Crates.io | array-mumu |
| lib.rs | array-mumu |
| version | 0.2.0-rc.5 |
| created_at | 2025-07-01 06:46:13.493681+00 |
| updated_at | 2025-10-07 11:19:17.298024+00 |
| description | Array tools plugin for the Mumu ecosystem |
| homepage | https://lava.nu11.uk |
| repository | https://gitlab.com/tofo/mumu-array |
| max_upload_size | |
| id | 1732829 |
| size | 293,546 |
A MuMu/Lava plugin to provide fast, typed & heterogeneous array utilities with friendly currying, data-last ergonomics, and keyed-object helpers.
Repository: https://gitlab.com/tofo/mumu-array
License: MIT OR Apache-2.0
Engine compatibility: core-mumu = 0.9.0-rc.4 (host and wasm builds)
array:* functions to MuMu/Lava_) and data-last calling stylesMixedArray otherwise)The plugin registers all symbols via register_all(interp). On native builds it also exports a dynamic entrypoint Cargo_lock(...) so extend("array") can load it at runtime.
array:length(arr) — to return size (arrays/2D/keyed arrays or string length)array:head(arr) / array:last(arr) — to return first/last or _ if emptyarray:nth(index, arr) — to return item at index (negatives from end) or _array:includes(item, arr) — to test membershiparray:find(pred, arr) / array:findIndex(pred, arr) — to return first match or -1array:map(fn, arr) / array:filter(pred, arr) / array:reduce(fn, [init], arr)array:each(fn, arr) — to apply for side-effects, returning original dataarray:flatten(arr) / array:flatten_deep(arr) / array:compact(arr) / array:reverse(arr)array:slice(start, end, arr) / array:take(n, arr) / array:drop(n, arr)array:take_while(pred, arr) / array:drop_while(pred, arr)array:init(arr) / array:tail(arr) / array:range(start, end) / array:repeat(value, n)array:chunk(size, arr) — to chunk; returns typed 2D arrays for uniform numeric rowsAll of the above are curry-able and accept _ as a placeholder.
array:sort(arr) — to default-sort typed arrays or pass through MixedArrayarray:sort_by(keyFn, arr) — to stable-sort by extracted keyarray:sort_with([cmp...], arr) — to stable-sort with one or more comparator functionsComparators must return negative / zero / positive (int/long/float). Ties are stable.
array:uniq(arr) / array:shuffle(arr)array:multi_union(a, b) / array:multi_intersection(a, b) / array:multi_difference(a, b)array:multi_concat(a, b) — to concatenate while preserving type when possiblearray:keys(obj) — to return StrArray of keysarray:prop(key, obj) / array:pluck(key, arrayOfObjs) — to select propertiesarray:assoc(key, value, obj) — to upsert key/value (returns a new keyed array)array:key_eq(expected, key, obj) — to test obj[key] == expected (Ramda-like propEq)array:group_by(keyFn, arr) — to return keyed array of grouped MixedArray valuesarray:collect(iter) — to collect iterator values into a typed or mixed arrayarray:apply(fn, argsArrayOrIter) — to apply a function to a list/iterator of argumentsstep(start, end)) and plugin iterators.array:zip(a, b) / array:zip_with(fn, a, b)array:append(item, arr) — to push or concatenate when stringsarray:join(sep, arr) — to join string collectionsAll multi-arg functions support:
currying with _ placeholders:
extend("array")
onlyOdds = array:filter(x => x % 2 != 0)
onlyOdds([1,2,3,4,5]) // [1,3,5]
data-last ergonomics for many functions (e.g., map, filter, reduce, slice, take, drop):
array:slice(1, -1, [10,20,30,40]) // [20,30]
negative indices where natural (e.g., array:nth(-1, xs) picks the last element).
Return conventions
_findIndex) → -1"array:<fn> => ...")IntArray, FloatArray, StrArray, BoolArray.MixedArray; many transforms up-cast to typed arrays when all elements agree.chunk(size, arr) returns Int2DArray / Float2DArray when rows are uniform; otherwise a MixedArray of row arrays.group_by, assoc) preserve insertion order of keys.apply accepts function plus MixedArray/typed arrays/iterators as the argument list.map intentionally rejects tensors in this build.extend("array")
xs = [1,2,3,4,5]
array:map(x => x * 2, xs) // [2,4,6,8,10]
array:filter(x => x % 2 == 0, xs) // [2,4]
array:reduce((acc, x) => acc + x, 0, xs) // 15
people = [[name:"Ada", age:36], [name:"Ben", age:29]]
array:keys(people[0]) // ["name","age"]
array:pluck("name", people) // ["Ada","Ben"]
array:sort_by(p => p:age, people) // age-ascending
// Partials & placeholders
take3 = array:take(3)
take3([9,8,7,6]) // [9,8,7]
assocCity = array:assoc("city")
assocCity("Oslo", [name:"Kai"]) // [name:"Kai", city:"Oslo"]
// Iterators
array:collect(step(3, 7)) // [3,4,5,6]
MixedArray otherwise.sort_by and sort_with.Cargo_lock for extend("array")array_mumu::register_all(&mut interp)array:map currently rejects Tensor values.IntArray([n])) for ergonomics.Issues and merge requests are welcome at:
https://gitlab.com/tofo/mumu-array
Please align changes with the MuMu core conventions:
Licensed under either of:
at your option.