Consider changing "not-found" behavior of `N`/`.N`
nick-paul opened this issue · 1 comments
nick-paul commented
Originally brought up by @BlazingTwist here
The N
operator returns -1
if it cannot find a value in a list. More recently, negative index support was added to Aya. -1
is no longer a good candidate for a default value since it is a valid index.
Possible options:
N
returnlength(list)+1
for not found- More difficult to use
N
as a basic contains operator since the index will need to be compared with the length of the list instead of with a known constant- Current way to check if a value is in a list:
N0<!
- New way to check if a value is in a list (compare with length of list):
N\.E@=
- Current way to check if a value is in a list:
- More difficult to use
- Possibly utilize unused
:N
operator for plain contains checking (return 1 if item is in list, 0 otherwise)
BlazingTwist commented
N
returnlength(list)+1
for not found
- More difficult to use
N
as a basic contains operator since the index will need to be compared with the length of the list instead of with a known constant
If you have the index-of operators return 0 list EB -
, that index will be out of bounds while still supporting N0<!