(rontolisp) docs
← Maps, sets and vectors

assoc

(assoc m k v ...)

Answers a fresh map over m's pairs plus the given ones, later pairs winning; m is never mutated. assoc onto nil builds from empty. Odd pair counts are refused. Keys compare by =: a key = to one already there replaces its value and keeps that key.

Onto a record the entries join the entry table and the type survives.

Onto a vector each key is an index: a fresh vector with that member replaced, an index equal to the count appending, like the oracle. A non-integer key signals Key must be integer, an index out of range signals. The copy is the whole vector (the oracle's persistent vector copies one path).

As a value a map plus a rest list of pairs; an odd rest count signals at run time.

Transients (assoc!) are refused by name.