feat: add List.index

This commit is contained in:
Shunsuke Shibayama 2024-08-08 19:59:09 +09:00
parent 5db5f8bd85
commit dcbd328b78
2 changed files with 9 additions and 0 deletions

View file

@ -63,3 +63,10 @@
assert [1, 2, 3, 4, 5].from(2) == [3, 4, 5]
'''
from: |T: Type|(self: List(T, _), nth: Nat) -> List(T, _)
'''
Return the index of the first occurrence of `x` in the array.
'''
'''erg
assert [1, 2, 3].index(2) == 1
'''
index: |T: Type|(self: List(T, _), x: T) -> Nat