![]() |
|
Navigation |
Synopsis Index of first occurrence of an element in a list.
Function
int indexOf(list[&T] lst, &T elt)
Usage
import List;
Description Return index of first occurrence of
elt in lst , or -1 if elt is not found.
Also see lastIndexOf.
Examples
rascal>import List; ok rascal>indexOf([3, 1, 4, 5], 4); int: 2 rascal>indexOf([3, 1, 4, 5], 7); int: -1 rascal>indexOf(["zebra", "elephant", "snake", "owl"], "snake"); int: 2 rascal>indexOf(["zebra", "elephant", "snake", "owl"], "eagle"); int: -1 Questions
Question [1].
![]() ![]()
Question [2].
![]() ![]() ![]() |