public class FP extends Object
Constructor and Description |
---|
FP() |
Modifier and Type | Method and Description |
---|---|
static <IN> boolean |
every(Iterable<IN> ins,
Fn<IN,?> filterFn)
Check if every Object passes Fn (same as forAll())
|
static <IN> boolean |
exists(Iterable<IN> ins,
Fn<IN,?> filterFn)
Check if any Object passes Fn (same as some() and Groovy's any())
|
static <IN> ArrayList<IN> |
filter(Iterable<IN> ins,
Fn<IN,?> filterFn)
Filter (keep) Objects accepted by Fn to a new ArrayList.
|
static <IN> IN |
fold(IN seed,
Iterable<IN> ins,
Fn<IN,IN> fn)
Fold objects using a generified Fn function
|
static double |
foldp(double seed,
double[] ins,
Fn.Pdouble fn)
Fold doubles using a primitive double (Fn.Pdouble) function
|
static int |
foldp(int seed,
int[] ins,
Fn.Pint fn)
Fold ints using a primitive int (Fn.Pint) function
|
static <IN> IN |
foldRight(IN seed,
List<IN> ins,
Fn<IN,IN> fn)
FoldRight objects using a generified Fn function
|
static double |
foldRightp(double seed,
double[] ins,
Fn.Pdouble fn)
FoldRight doubles using a primitive double (Fn.Pdouble) function
|
static int |
foldRightp(int seed,
int[] ins,
Fn.Pint fn)
FoldRight ints using a primitive int (Fn.Pint) function
|
static <IN> boolean |
forAll(Iterable<IN> ins,
Fn<IN,?> filterFn)
Check if every Object passes Fn (same as every())
|
static int |
indexOf(Object grail,
Object... array)
Find index of grail in array, usually using equals()
|
static int |
indexOfByRef(Object grail,
Object... array)
FInd index of grail in array, using ==
|
static boolean |
isFalse(Object o)
For a filter function (filterFn in formal arguments above) converts their output to true/false
|
static boolean |
isTrue(Object o)
For a filter function (filterFn in formal arguments above) converts their output to true/false
|
static String |
join(Iterable ins)
Default uses comma delim
|
static String |
join(Object... ins) |
static String |
join(String delim,
Iterable ins)
Join Objects into a String.
|
static <IN,OUT> ArrayList<OUT> |
map(Iterable<IN> ins,
Fn<IN,OUT> fn)
Map all Objects to a new List, transforming them via Fn
|
static <IN> IN |
reduce(Iterable<IN> ins,
Fn<IN,IN> fn)
Reduce Objects using a generified Fn function
|
static double |
reducep(double[] ins,
Fn.Pdouble fn)
Reduce doubles using a primitive double (Fn.Pdouble) function
|
static int |
reducep(int[] ins,
Fn.Pint fn)
Reduce ints using a primitive int (Fn.Pint) function
|
static <IN> boolean |
some(Iterable<IN> ins,
Fn<IN,?> fn)
Check if any Object passes Fn (same as exists())
|
public static <IN> IN fold(IN seed, Iterable<IN> ins, Fn<IN,IN> fn)
public static double foldp(double seed, double[] ins, Fn.Pdouble fn)
public static int foldp(int seed, int[] ins, Fn.Pint fn)
public static <IN> IN foldRight(IN seed, List<IN> ins, Fn<IN,IN> fn)
public static double foldRightp(double seed, double[] ins, Fn.Pdouble fn)
public static int foldRightp(int seed, int[] ins, Fn.Pint fn)
public static <IN> IN reduce(Iterable<IN> ins, Fn<IN,IN> fn)
public static double reducep(double[] ins, Fn.Pdouble fn)
public static int reducep(int[] ins, Fn.Pint fn)
public static <IN> ArrayList<IN> filter(Iterable<IN> ins, Fn<IN,?> filterFn)
IN
- type of Objectsins
- inputObjectsfilterFn
- return null or Boolean.FALSE to eliminate Objectspublic static <IN,OUT> ArrayList<OUT> map(Iterable<IN> ins, Fn<IN,OUT> fn)
IN
- type of input ObjectsOUT
- type of result Objectsins
- inputObjectsfn
- maps from IN to OUTpublic static <IN> boolean every(Iterable<IN> ins, Fn<IN,?> filterFn)
IN
- ins
- if empty returns truefilterFn
- Return null or Boolean.FALSE to reject a valuepublic static <IN> boolean exists(Iterable<IN> ins, Fn<IN,?> filterFn)
IN
- ins
- if empty returns falsefilterFn
- Return null or Boolean.FALSE to reject a valuepublic static <IN> boolean forAll(Iterable<IN> ins, Fn<IN,?> filterFn)
IN
- ins
- if empty returns truefilterFn
- Return null or Boolean.FALSE to reject a valuepublic static int indexOf(Object grail, Object... array)
grail
- array
- public static int indexOfByRef(Object grail, Object... array)
grail
- may be nullarray
- public static String join(String delim, Iterable ins)
delim
- delimiter, non-null but may be ""ins
- public static <IN> boolean some(Iterable<IN> ins, Fn<IN,?> fn)
IN
- ins
- if empty returns falsefn
- Return null or Boolean.FALSE to reject a valuepublic static boolean isTrue(Object o)
o
- public static boolean isFalse(Object o)
o
-