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.
index-ofworks on strings (returning the byte index or-1), butthere is no equivalent for vectors.
findreturns the matchingelement rather than its position;
indicesis not in the VMbuiltin set.
Proposal
[index-of xs elem]->Int(the position,-1if absent), orreturn
Option Int, mirroring the chosen Option story.position/find-index.Acceptance criteria
ref/builtins.loon.