org.xmloperator.lambda.tree.generate
Class ChurchNumerals

java.lang.Object
  |
  +--org.xmloperator.lambda.tree.generate.ChurchNumerals

public abstract class ChurchNumerals
extends java.lang.Object

Factories for Church numerals.


Constructor Summary
ChurchNumerals()
           
 
Method Summary
static int intValue(Abstraction abstraction)
          Returns the integer value of a Church numeral or -1 if the argument is not a Church numeral.
static void main(java.lang.String[] args)
           
static Abstraction newAdd(TermFactory termFactory)
          Creates and returns a new instance of the "Add" Abstraction ("aaaacceeevevcceevevv").
static Abstraction newExp(TermFactory termFactory)
          Creates and returns a new instance of the "Exp" Abstraction ("aacvev").
static Abstraction newInt(TermFactory termFactory, int n)
          Creates and returns a new instance of the Abstraction that represents the integer n: 0 = "aav", 1 = "aacevv", 2 = "aacevcevv", 3 = "aacevcevcevv", ...
static Abstraction newMult(TermFactory termFactory)
          Creates and returns a new instance of the "Mult" Abstraction ("aaaceevcevv").
static Abstraction newSucc(TermFactory termFactory)
          Creates and returns a new instance of the "Succ" Abstraction ("aaacevcceevevv").
static Abstraction newZero(TermFactory termFactory)
          Creates and returns a new instance of the "Zero" Abstraction ("aaacceevcKvev").
static boolean test(java.io.PrintStream out, boolean isVerbose)
          Execute some operations using Church numerals.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChurchNumerals

public ChurchNumerals()
Method Detail

newInt

public static final Abstraction newInt(TermFactory termFactory,
                                       int n)
Creates and returns a new instance of the Abstraction that represents the integer n:

Parameters:
termFactory - a TermFactory.
n - the integer to represent.
Returns:
the Church numeral Abstraction.
Throws:
java.lang.IllegalArgumentException - if the integer n is negative.

intValue

public static final int intValue(Abstraction abstraction)
Returns the integer value of a Church numeral or -1 if the argument is not a Church numeral.

Parameters:
abstraction - the Church numeral.
Returns:
the value of the Church numeral or -1 if the argument is not a Church numeral.
Throws:
java.lang.NullPointerException - if the given Abstraction is broken.

newSucc

public static final Abstraction newSucc(TermFactory termFactory)
Creates and returns a new instance of the "Succ" Abstraction ("aaacevcceevevv").

Parameters:
termFactory - an TermFactory.
Returns:
the "Succ" Abstraction.

newZero

public static final Abstraction newZero(TermFactory termFactory)
Creates and returns a new instance of the "Zero" Abstraction ("aaacceevcKvev").

Parameters:
termFactory - an TermFactory.
Returns:
the "Zero" Abstraction.

newAdd

public static final Abstraction newAdd(TermFactory termFactory)
Creates and returns a new instance of the "Add" Abstraction ("aaaacceeevevcceevevv").

Parameters:
termFactory - an TermFactory.
Returns:
the "Add" Abstraction.

newMult

public static final Abstraction newMult(TermFactory termFactory)
Creates and returns a new instance of the "Mult" Abstraction ("aaaceevcevv").

Parameters:
termFactory - an TermFactory.
Returns:
the "Mult" Abstraction.

newExp

public static final Abstraction newExp(TermFactory termFactory)
Creates and returns a new instance of the "Exp" Abstraction ("aacvev").

Parameters:
termFactory - an TermFactory.
Returns:
the "Exp" Abstraction.

main

public static void main(java.lang.String[] args)

test

public static boolean test(java.io.PrintStream out,
                           boolean isVerbose)
Execute some operations using Church numerals.

Parameters:
out - the PrintStream to print results. May be null.
isVerbose - if true then all tests have to be displayed.
Returns:
true if all is Ok.