Class IntOperation

java.lang.Object
  extended by IntOperation
All Implemented Interfaces:
Function

public abstract class IntOperation
extends java.lang.Object
implements Function

An abstract base class for integer arithmetic functions such as +. These functions are all "curried", which means that they expect one argument (the left operand) and then produce a new function which in turn expects one argument (the right operand) before producing the final result of the arithmetic. This is necessary because we are requiring all functions to take just one argument.


Constructor Summary
IntOperation()
           
 
Method Summary
 java.lang.Object apply(java.lang.Object arg1)
          Apply this function to a specified argument value.
abstract  int compute(int i1, int i2)
          This method should be implemented in each concrete subclass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntOperation

public IntOperation()
Method Detail

compute

public abstract int compute(int i1,
                            int i2)
This method should be implemented in each concrete subclass. This is where the actual operation takes place, whether that be +, -, or whatnot.

Parameters:
i1 - the left operand
i2 - the right operand
Returns:
the result of the computation on i1 and i2

apply

public java.lang.Object apply(java.lang.Object arg1)
Description copied from interface: Function
Apply this function to a specified argument value.

Specified by:
apply in interface Function
Parameters:
arg1 - the argument value
Returns:
the result value from the function application.