mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
feat: add List.index
This commit is contained in:
parent
5db5f8bd85
commit
dcbd328b78
2 changed files with 9 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue