commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodney Waldhoff <rwaldh...@apache.org>
Subject Re: [FUNCTOR] Does functor have a class for this?
Date Fri, 26 Mar 2004 00:44:16 GMT
I don't think functor currently has a direct representation of this
concept, although you could fabricate one out of some of the existing
concepts.  See the composite and adapter packages for example.

UnaryCompositeBinaryPredicate is similar to what you're looking for, but
that expects two unary functions and exposes a binary predicate.  You
could start with that and build up to BinaryPredicateToPredicate using
currying, or simply implement it as a new class, as you've done here.


On Thu, 18 Mar 2004, James Carman wrote:

> I want to turn a BinaryPredicate into a Predicate by using Functions for the
> left/right operands to the BinaryPredicate.
>
>
>
> public class BinaryPredicateToPredicate implements Predicate
>
> {
>
>   private final Function leftFunction;
>
>   private final Function rightFunction;
>
>   private final BinaryPredicate binaryPredicate;
>
>
>
>   public BinaryPredicateToPredicate( BinaryPredicate binaryPredicate,
> Function leftFunction, Function rightPredicate )
>
>   {
>
>     this.leftFunction = leftFunction;
>
>     this.rightFunction = rightFunction;
>
>     this.binaryPredicate = binaryPredicate;
>
>   }
>
>
>
>   public boolean test()
>
>   {
>
>     binaryPredicate.test( leftFunction.evaluate(), rightFunction.evaluate()
> );
>
>   }
>
> }
>
>
>
> Does the functor library already have something for this?
>
>
>
>

-- 
- Rod <http://radio.weblogs.com/0122027/>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message