position(obj, xs, @key start = 0, test = is_eq)
Compare each element in the list xs
to obj
using the predicate test
.
The comparison begins at the index specified by start
.
Return the index of obj
in the list xs
.
Return false
if obj
is not found in the list.
position(10, [1, 2, 10, 3])
// 2
position("hi", [1, 2, "hi", 3])
// false
position("hi", [1, 2, "hi", 3], test = is_equal)
// 2
position("hi", [1, 2, "hi", 3], test = is_equal, start = 3)
// false
position("hi", [1, 2, "hi", 3], test = is_equal, start = 2)
// 2