Mango defines a variety of function types
Generator describes a function which takes no arguments - fn(). It returns some object of type
R, and may return the same object or different objects for each invocation. It can refer to local state, perform disk reads or writes, or whatever (although their bags either to test if they don't).
Function describes a function which takes one argument of type
T, fn(x). It returns some object of type
R, which may not be the same as type
T and may return the same object or different objects for each invocation, even given the same argument.
BinaryFunction is some function taking two arguments - fn(x, y). The arguments may be of the same or different types. It returns an object of type
R, which may or may not be of the same type as one of the arguments. It may return the same object or different objects for each invocation, even given the same arguments.
Predicate is a special form of unary function, whose result represents the truth or otherwise of some condition. It returns
true if the condition the
Predicate tests for is satisfied,
BinaryPredicate is some function taking two arguments - fn(x, y) and returning the result of some test. It returns
true if the test is met,
Many Mango algorithms take a
Function argument. Often though, the thing you'd really like to pass is a method on another object or a static class method. Mango's Adapt methods wrap up object methods into a
A binder converts a
BinaryPredicate) into a
Predicate) by fixing one of its inputs to a constant value. See the Javadoc for more information.