mumu 0.10.0

Lava Mumu is a language for those in the now and that know
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
  "id": "fn-array-assoc",
  "dataComponent": "array",
  "heading": {
    "title": "assoc",
    "badges": ["Array", "PARTIAL"]
  },
  "synopsis": "Sets or updates a key-value pair in a keyed array, returning a new keyed array. Supports placeholders for key, value, or object.",
  "codeBlocks": [
    "extend(\"array\")\\n\\nkeyed = [ name:\"Alice\" ]\\nsput( array:assoc(\"city\", \"London\", keyed) )\\n// => [ name:\"Alice\", city:\"London\" ]\\n\\n# Partial usage\\nsetter = array:assoc(\"color\", \"blue\")\\nsput( setter(keyed) )\\n// => [ name:\"Alice\", color:\"blue\" ]\\n\\n# Placeholder usage\\nbananaSetter = array:assoc(_, \"banana\", keyed)\\nsput( bananaSetter(\"fruit\") )\\n// => [ name:\"Alice\", fruit:\"banana\" ]"
  ],
  "notes": [
    "Expects (key, value, object). The object must be a KeyedArray. The key must be a single string. If the key already exists, its value is replaced.",
    "If you only supply (key, value), it returns a partial function waiting for the object. If you skip any of them with `_`, it returns a partial needing more calls.",
    "Raises an error if the object is not keyed or if the key is invalid."
  ]
}