Skip to content

[P1] assoc and update silently no-op on vectors (immutable index update unsupported) #21

Description

@ecto

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions