net.sf.jga.fn

Class AbstractBinaryFunctor<T1,T2,R>

public abstract class AbstractBinaryFunctor<T1,T2,R> extends Object implements BinaryFunctor<T1,T2,R>

Provides factory methods that ease the burden of constructing complex functional expressions with BinaryFunctors.

Author: David A. Hall

Method Summary
voidaccept(Visitor v)
No-op implementation of Visitable interface.
UnaryFunctor<T2,R>bind1st(T1 value)
Factory method that creates a UnaryFunctor that binds a constant value to this' first argument.
UnaryFunctor<T1,R>bind2nd(T2 value)
Factory method that creates a UnaryFunctor that binds a constant value to this' second argument.
<F> UnaryFunctor<F,R>compose(UnaryFunctor<F,T1> g, UnaryFunctor<F,T2> h)
FactoryMethod that creates a UnaryFunctor that passes its argument to each of the given functors, and uses the results as the arguments to this function.
<F1,F2> BinaryFunctor<F1,F2,R>compose(BinaryFunctor<F1,F2,T1> g, BinaryFunctor<F1,F2,T2> h)
FactoryMethod that creates a BinaryFunctor that passes its arguments to each of the given functors, and uses the results as the arguments to this function.
<F1,F2> BinaryFunctor<F1,F2,R>distribute(UnaryFunctor<F1,T1> g, UnaryFunctor<F2,T2> h)
FactoryMethod that creates a BinaryFunctor that passes each of its two arguments to a pair of UnaryFunctors, then uses the results as arguments to this function.

Method Detail

accept

public void accept(Visitor v)
No-op implementation of Visitable interface.

bind1st

public UnaryFunctor<T2,R> bind1st(T1 value)
Factory method that creates a UnaryFunctor that binds a constant value to this' first argument. Given argument x, the new functor will return fnthis(value, x)

bind2nd

public UnaryFunctor<T1,R> bind2nd(T2 value)
Factory method that creates a UnaryFunctor that binds a constant value to this' second argument. Given argument x, the new functor will return fnthis(x, value)

compose

public <F> UnaryFunctor<F,R> compose(UnaryFunctor<F,T1> g, UnaryFunctor<F,T2> h)
FactoryMethod that creates a UnaryFunctor that passes its argument to each of the given functors, and uses the results as the arguments to this function. Given argument x, the new functor will return fnthis(g(x), h(x))

compose

public <F1,F2> BinaryFunctor<F1,F2,R> compose(BinaryFunctor<F1,F2,T1> g, BinaryFunctor<F1,F2,T2> h)
FactoryMethod that creates a BinaryFunctor that passes its arguments to each of the given functors, and uses the results as the arguments to this function. Given arguments x and y, the new functor will return fnthis(g(x,y), h(x,y))

distribute

public <F1,F2> BinaryFunctor<F1,F2,R> distribute(UnaryFunctor<F1,T1> g, UnaryFunctor<F2,T2> h)
FactoryMethod that creates a BinaryFunctor that passes each of its two arguments to a pair of UnaryFunctors, then uses the results as arguments to this function. Given arguments x and y, the new functor will return fnthis(g(x), h(y)). Note: this method cannot be called compose, as it is only distinct from the unary form of compose in its param types and its return type