Mango defines a variety of function types

It also includes function adaptors and binders.

Generators

A 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).

See Functions.

Functions

A 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.

See Functions.

Binary Functions

A 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.

See BinaryFunctions.

Predicates

A 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, false otherwise.

Mango includes the following canned Predicates: All, Any, OneOf, And, Or, Not, Nand, Nor, Xor, Xnor, True, False, Constant, NotNull, and IsNull.

Binary Predicates

A 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, false otherwise.

Mango provides EqualTo, NotEqualTo, GreaterThan, GreaterThanEquals, LessThan, LessThanEquals, Not, And, Or. True, False, and Constant,

Adaptors

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 Function.

Binders

A binder converts a BinaryFunction (or BinaryPredicate) into a Function (or Predicate) by fixing one of its inputs to a constant value. See the Javadoc for more information.


Jez Higgins