assoc and update work on maps but silently return the original
vector when called with a vector + integer index:
[assoc {:a 1} :b 2] ; {:b 2 :a 1} -- works
[assoc #[1 2 3] 0 9] ; #[1 2 3] -- silent no-op
[update #[1 2 3] 0 [fn [x] 9]] ; #[1 2 3] -- silent no-op
There is no immutable index-update for vectors today, and the silent
no-op makes this look like the operation succeeded.
Acceptance criteria
- Either make
assoc/update work on vectors with integer indices,
returning a new vector — [assoc #[1 2 3] 0 9] -> #[9 2 3] — or
raise a clear error when the wrong combination of types is passed.
- Add a
set / assoc-in / equivalent if a different name is preferred.
- Document in
ref/builtins.loon.
assocandupdatework on maps but silently return the originalvector when called with a vector + integer index:
There is no immutable index-update for vectors today, and the silent
no-op makes this look like the operation succeeded.
Acceptance criteria
assoc/updatework on vectors with integer indices,returning a new vector —
[assoc #[1 2 3] 0 9]->#[9 2 3]— orraise a clear error when the wrong combination of types is passed.
set/assoc-in/ equivalent if a different name is preferred.ref/builtins.loon.