Skip to main content

Pair.find

findpredicatestart if_missing

Group: Selections

Documentation

Returns the first element of the pair that satisfies the predicate or if no elements satisfy the predicate, returns if_missing.

Arguments

  • predicate: A function that takes a list element and returns a boolean value that says whether that value satisfies the conditions of the function.
  • start: The index to start searching from. If the index is negative, it is counted from the end of the pair.
  • if_missing: Value returned if no element satisfies the predicate.

Examples

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

      Pair.new 1 6 .find (> 3)