find

Definition: integer i = find(object x, sequence s, integer start=1)
-- or --
integer i = rfind(object x, sequence s, integer start=-1)
Description: Find x as an element of s. If successful, return the index of the first element of s that matches. If unsuccessful return 0.

The start index may optionally be specified, as per example 3 below.

The rfind routine is identical but works from the end of s to the start.

The find_from() routine, which predated optional parameters, is now deprecated. Simply use find() with the optional third parameter instead.
Example 1:
location = find(11, {5, 8, 11, 2, 3})
-- location is set to 3
Example 2:
names = {"fred", "rob", "george", "mary", ""}
location = find("mary", names)
-- location is set to 4
Example 3:
idx = find(8, {5, 8, 11, 8, 11}, 3)
-- idx is set to 4; the matching value at [2] was obviously skipped/not  
--                  examined because a start index of 3 was specified.
See Also: match, compare