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].
The type of indexOf([-2, 12, -10, 18, -3, 6], -10) is

Question [2].
indexOf([-19, 10, -10, 17, -10, 13], -19) == 



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.