Skip to content

[P2] No way to find the index of an element in a vector #25

@ecto

Description

@ecto

index-of works on strings (returning the byte index or -1), but
there is no equivalent for vectors. find returns the matching
element rather than its position; indices is not in the VM
builtin set.

Proposal

  • [index-of xs elem] -> Int (the position, -1 if absent), or
    return Option Int, mirroring the chosen Option story.
  • Or add position / find-index.

Acceptance criteria

  • Builtin available in the VM and documented in ref/builtins.loon.
  • Tests for hit, miss, first element, last element, duplicates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions