index function

Syntax

  • float index(float[] array, float item)
  • float index(float[] array, float item, float epsilon)
  • float index(string[] array, string item)
  • float index(bool[] array, bool item)

Parameters

  1. array
    Array for which an index is requested.
  2. item
    Item value to look for.
  3. epsilon
    A tolerance in which float item values are considered to be equal. Default is 0.

Returns

The index of the first occurrence of item. If item is not found -1 is returned.

Description

The index function can be used to find a specific item value in an array. An epsilon tolerance can be specified in order to deal with floating point imprecision.

Related

Examples

Print index

const indices = comp(fe) { all : comp.index }

Example --> print(indices)              // (4)[0,1,2,4]
            print(index(indices, 1))    // 1
            print(index(indices, 2, 1)) // 1

In this topic