Skip to main content

Vector.find

findcondition start if_missing

Group: Selections

Documentation

Returns the first element of the vector that satisfies the condition or if_missing if no elements of the vector satisfy it.

Arguments

  • condition: A Filter_Condition or a function that takes an element and returns a boolean value specifying if it satisfies the condition.
  • start: The index to start searching from. If the index is negative, it is counted from the end of the vector.
  • if_missing: Value returned if no element satisfies the predicate.

Examples

Finding a first element of the vector that is larger than 3.

      [1, 2, 3, 4, 5].find (> 3)