commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodney Waldhoff <>
Subject Re: [functor] predicates
Date Mon, 28 Apr 2003 14:54:07 GMT
You can use a process known as Currying to convert a binary function to a
unary one.  There are types in functor.adapater for binding a constant
value to the left-side or right-side argument of BinaryFunction,
BinaryPredicate or BinaryProcedure, yielding a UnaryFunction,
UnaryPredicate or UnaryProcedure, respectively.

For example,

 UnaryPredicate isLessThan7 = new RightBoundPredicate(
     new IsLessThan(),
     new Integer (7));

Hence, to select all the elements of myCollection less than 7, use:, isLessThan7);

- Rod <>

On Mon, 28 Apr 2003, Jason Horman wrote:

> Many of the comparator predicates are BinaryPredicates. Should then not be
> both binary and unary. For example, the IsLessThan predicate is strictly
> binary, rendering it useless for
>, etc. Or would it make more
> sense to renamed the existing binary predicates to BinaryIsLessThan and
> create a UnaryIsLessThan?
> -jason
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message