Package edu.rice.cs.plt.lambda

A collection of interfaces facilitating first-class functions in Java.

See:
          Description

Interface Summary
Box<T> A thunk with a mutable value.
Condition An arbitrary nullary predicate.
Lambda<T,R> An arbitrary piece of code parameterized by an argument.
Lambda2<T1,T2,R> An arbitrary piece of code parameterized by two arguments.
Lambda3<T1,T2,T3,R> An arbitrary piece of code parameterized by three arguments.
Lambda4<T1,T2,T3,T4,R> An arbitrary piece of code parameterized by four arguments.
LambdaUtil.GeneralLambda<R> An object that functions as a lambda for all arities.
LambdaUtil.GeneralPredicate An object that functions as a predicate for all arities.
LambdaUtil.GeneralRunnable An object that functions as a runnable for all arities.
LambdaUtil.LiftedLambda<T,R> A Lambda that accepts and produces Option values.
LambdaUtil.LiftedLambda2<T1,T2,R> A Lambda2 that accepts and produces Option values.
LambdaUtil.LiftedLambda3<T1,T2,T3,R> A Lambda3 that accepts and produces Option values.
LambdaUtil.LiftedLambda4<T1,T2,T3,T4,R> A Lambda4 that accepts and produces Option values.
Predicate<T> An arbitrary predicate for values of type T.
Predicate2<T1,T2> An arbitrary binary predicate for values of type T1 and T2.
Predicate3<T1,T2,T3> An arbitrary ternary predicate for values of type T1, T2, and T3.
Predicate4<T1,T2,T3,T4> An arbitrary quaternary predicate for values of type T1, T2, T3, and T4.
ResolvingThunk<R> A thunk that may be in a "resolved" or "unresolved" state.
Runnable1<T> A lambda that doesn't have a return value (relying instead on side effects).
Runnable2<T1,T2> A binary lambda that doesn't have a return value (relying instead on side effects).
Runnable3<T1,T2,T3> A ternary lambda that doesn't have a return value (relying instead on side effects).
Runnable4<T1,T2,T3,T4> A quaternary lambda that doesn't have a return value (relying instead on side effects).
Thunk<R> An arbitrary piece of code that returns a value with the provided type.
 

Class Summary
CachedThunk<R> A thunk that caches the result of a nested thunk on the first invocation of value().
DelayedThunk<R> A thunk whose value is set once after creation, but before the first invocation of DelayedThunk.value().
LambdaUtil A collection of constants and static methods that define or operate on lambdas, runnables, and predicates.
LambdaUtilTest  
LazyRunnable A block of code that executes at most once.
LazyThunk<R> A thunk providing call-by-need evaluation of the nested thunk, value.
SimpleBox<T> A box that freely supports reads and writes.
 

Exception Summary
WrappedException A wrapper for checked exceptions, allowing them to be thrown by lambda code (and in other situations in which an interface does not allow checked exceptions to be thrown).
 

Package edu.rice.cs.plt.lambda Description

A collection of interfaces facilitating first-class functions in Java. Three families of interfaces are defined, each with variants for 0 to 4 arguments:

Since it's impossible to define a type-safe lambda with an arbitrary number of arguments, a practical limit of 4 is set, and each variation is represented by a distinct interface.

In addition to the above interfaces, a few general-purpose implementations are provided, such as LazyThunk and Box The LambdaUtil class defines static constants and methods that define and act on lambdas, allowing easy null-valued and literal-valued lambda creation, composition, currying, negation, conjunction, disjunction, conversion between types, etc.