Package fj.function

Class Booleans

java.lang.Object
fj.function.Booleans

public final class Booleans extends Object
Curried logical functions.
  • Field Details

  • Constructor Details

    • Booleans

      private Booleans()
  • Method Details

    • and

      public static boolean and(List<Boolean> l)
      Returns true if all the elements of the given list are true.
      Parameters:
      l - A list to check for all the elements being true.
      Returns:
      true if all the elements of the given list are true. False otherwise.
    • contramap

      public static <A, B> F<B,Boolean> contramap(F<B,A> f, F<A,Boolean> p)
      maps given function to the predicate function
      Parameters:
      f - function
      p - predicate to be mapped over
      Returns:
      predicate function
    • is

      public static <A, B> F<B,Boolean> is(F<B,A> f, F<A,Boolean> p)
      alias for contramap
      Parameters:
      f - function
      p - predicate to be mapped over
      Returns:
      predicate function
    • isnot

      public static <A, B> F<B,Boolean> isnot(F<B,A> f, F<A,Boolean> p)
      returns inverse of contramap
      Parameters:
      f - function
      p - predicate to be mapped over
      Returns:
      predicate function
    • and

      public static <A> F<A,Boolean> and(F<A,Boolean> p1, F<A,Boolean> p2)
      composes the given predicate using conjunction
      Parameters:
      p1 - first predicate
      p2 - second predicate
      Returns:
      composed predicate function
    • xor

      public static <A> F<A,Boolean> xor(F<A,Boolean> p1, F<A,Boolean> p2)
      composes the given predicate using exclusive disjunction
      Parameters:
      p1 - first predicate
      p2 - second predicate
      Returns:
      composed predicate function
    • or

      public static <A> F<A,Boolean> or(F<A,Boolean> p1, F<A,Boolean> p2)
      returns composed predicate using disjunction
      Parameters:
      p1 - first predicate
      p2 - second predicate
      Returns:
      composed predicate
    • and

      public static boolean and(Stream<Boolean> l)
      Returns true if all the elements of the given stream are true.
      Parameters:
      l - A stream to check for all the elements being true.
      Returns:
      true if all the elements of the given stream are true. False otherwise.
    • andAll

      public static <A> F<A,Boolean> andAll(Stream<F<A,Boolean>> l)
      Returns composed predicate
      Parameters:
      l - A stream of predicates
      Returns:
      composed predicate
    • andAll

      public static <A> F<A,Boolean> andAll(List<F<A,Boolean>> l)
      Returns a composed predicate of given List of predicates
      Parameters:
      l - A list of predicate functions
      Returns:
      composed predicate function
    • orAll

      public static <A> F<A,Boolean> orAll(List<F<A,Boolean>> l)
      Returns a composed predicate of given List of predicates
      Parameters:
      l - A list of predicate functions
      Returns:
      composed predicate function
    • orAll

      public static <A> F<A,Boolean> orAll(Stream<F<A,Boolean>> l)
      Returns a composed predicate of given Stream of predicates
      Parameters:
      l - A stream of predicate functions
      Returns:
      composed predicate function
    • or

      public static boolean or(List<Boolean> l)
      Returns true if any element of the given list is true.
      Parameters:
      l - A list to check for any element being true.
      Returns:
      true if any element of the given list is true. False otherwise.
    • or

      public static boolean or(Stream<Boolean> l)
      Returns true if any element of the given stream is true.
      Parameters:
      l - A stream to check for any element being true.
      Returns:
      true if any element of the given stream is true. False otherwise.
    • not

      public static <A> F<A,Boolean> not(F<A,Boolean> p)
      Negates the given predicate.
      Parameters:
      p - A predicate to negate.
      Returns:
      The negation of the given predicate.
    • cond

      public static <A> F<Boolean,F<A,F<A,A>>> cond()
      Curried form of conditional. If the first argument is true, returns the second argument, otherwise the third argument.
      Returns:
      A function that returns its second argument if the first argument is true, otherwise the third argument.