findFirst function (builtin)

Syntax

float findFirst(array, value)

float findFirst(array, value, epsilon)

Parameters

Returns

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

Copyright ©2008-2024 Esri R&D Center Zurich. All rights reserved.