Class Find


public class Find extends PrimitiveFunction
Finds the first element in a list that satisfies the predicate.
  • Constructor Details

    • Find

      public Find()
  • Method Details

    • name

      public Name name()
      Description copied from class: PrimitiveFunction
      The unique name of the primitive function.
      Specified by:
      name in class PrimitiveFunction
      Returns:
      the name of this primitive function
    • type

      public TypeScheme type()
      Description copied from class: PrimitiveFunction
      The datatype of the primitive function.
      Specified by:
      type in class PrimitiveFunction
      Returns:
      the type scheme of this primitive function
    • implementation

      protected Function<List<Term>,Flow<Graph,Term>> implementation()
      Description copied from class: PrimitiveFunction
      A dynamic/interpreted implementation of the function.
      Specified by:
      implementation in class PrimitiveFunction
      Returns:
      the function implementation
    • apply

      public static <X> Function<List<X>,Maybe<X>> apply(Predicate<X> pred)
      Finds the first element in a list that satisfies the predicate.
      Type Parameters:
      X - the element type
      Parameters:
      pred - the predicate to test elements
      Returns:
      a function that finds the first matching element
    • apply

      public static <X> Maybe<X> apply(Function<X,Boolean> pred, List<X> lst)
      Finds the first element in a list that satisfies the predicate.
      Type Parameters:
      X - the element type
      Parameters:
      pred - the predicate as a Function (used by generated code)
      lst - the list to search
      Returns:
      an optional containing the first matching element, or empty if none found
    • apply

      public static <X> Maybe<X> apply(Predicate<X> pred, List<X> lst)
      Finds the first element in a list that satisfies the predicate.
      Type Parameters:
      X - the element type
      Parameters:
      pred - the predicate to test elements
      lst - the list to search
      Returns:
      an optional containing the first matching element, or empty if none found