Specifically, I\'m looking for similarly clean notation to the Collection
/ Exists
, etc.
It feels smelly to have to wri
Functional Java provides first-class functions. A predicate is expressed as F
. For example, here's a program that tests an array for the existence of a string that is all lowercase letters.
import fj.F;
import fj.data.Array;
import static fj.data.Array.array;
import static fj.function.Strings.matches;
public final class List_exists {
public static void main(final String[] args) {
final Array a = array("Hello", "There", "how", "ARE", "yOU?");
final boolean b = a.exists(matches.f("^[a-z]*$"));
System.out.println(b); // true
}
}