Navigation
Synopsis A list of legal index values of a list.
Function list[int] index(list[&T] lst)
Usage import List;
Description Returns a list of all legal index values for a given list lst.
Examples
rascal>import List;
ok
rascal>index([1, 3, 5]);
list[int]: [0,1,2]
rascal>index(["zebra", "elephant", "snake", "owl"]);
list[int]: [0,1,2,3]
Benefits This function is useful in For loops over lists.

Questions
Question [1]. The number of elements in the index of a list is:





Question [2].
The type of index(["H", "Vanilla", "Boba Fett", "Pincess Leia"]) is

Question [3].
index([]) == 



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.