findFirst function
float findFirst(array, value)
float findFirst(array, value, epsilon)
array float[]string[]bool[] Array for which an index of a value is requested. For float arrays an epsilon must be specified.
value floatstringbool Value to look for.
epsilon float Only applicable for float arrays. Float values within this tolerance are considered equal.
Returns the zero-based index of the first occurrence of value in array. If value is not found, -1 is returned.
Related
Examples
Basic example
const array1d = [1,2,3,4]
const array2d = [1,2,3;4,5,6]
Example --> print( findFirst(array1d, 2, 0) ) // 1
print(array1d[ findFirst(array1d, 2, 0) ]) // 2
print( findFirst(array2d, 4, 0) ) // 3
print(array2d[ findFirst(array2d, 4, 0) ]) // 4
Use float epsilon
const indices = comp(e) { all : scope.sx }
Example --> print(indices) // (4)[6,8.1,6,8.1]
print(findFirst(indices, 8, 0.5)) // 1