org.fun4j
Class PartialApplication

java.lang.Object
  extended by org.fun4j.PartialApplication
All Implemented Interfaces:
Function

public class PartialApplication
extends java.lang.Object
implements Function

A PartialApplication binds arguments to some or all of a functions variables. Thus a closure contains a Function and an array of Objects representing the values of the bound variables). A PartialApplication is a Function and can be executed with a call to apply(Object...). Example:

 // define a function with two variables 
 (define add (lambda (x y) (+ x y))) 
 
 // calling this function with only one argument results in a PartialApplication
 (define add17 (add 17)) ==> add0(args) => args[0] + args[1][17]
 
 // This closure is a function with only one free variable
 // Thus apply add17 to 4 returns 21:
 (add17 4) ==> 21
 

Author:
Thomas Mahler

Constructor Summary
PartialApplication(Function function, java.lang.Object[] arguments)
           
 
Method Summary
 java.lang.Object apply(java.lang.Object... boundArgs)
          Apply this function to the given arguments.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PartialApplication

public PartialApplication(Function function,
                          java.lang.Object[] arguments)
Method Detail

apply

public java.lang.Object apply(java.lang.Object... boundArgs)
Apply this function to the given arguments.

Specified by:
apply in interface Function
Parameters:
boundArgs - the arguments passed to the function call
Returns:
the result of applying the function to its arguments

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object