org.xmloperator.lambda2.term.util
Class Base2Numerals

java.lang.Object
  extended byorg.xmloperator.lambda2.term.util.Base2Numerals

public abstract class Base2Numerals
extends java.lang.Object

Numerals writeln in base 2.


Field Summary
static Abstraction HALF
          Term that represents the function that returns half the value of the argument.
static Application SUCCESSOR
          Term that represents the function that returns the successor of the value of the argument.
static Application THREE_N_PLUS_R
          Term that represents the function g(n, r) = 3 * n + r, with r = 0, 1 or 2.
static Abstraction TWICE0
          Term that represents the function that returns twice the value of the argument.
static Abstraction TWICE1
          Term that represents the function that returns twice the value of the argument plus one.
static Abstraction ZERO
          Term that represents the function that returns "K" if the argument is "0", "F" elsewhere.
 
Constructor Summary
Base2Numerals()
           
 
Method Summary
static long longValue(TermReducer termReducer, Term term)
          Returns the long value modulo 2^63 of the given base 2 numeral term.
static void main(java.lang.String[] args)
           
static Abstraction newInt(int n)
          Creates and returns a Term that represents an integer.
static Abstraction newTwice(boolean plusOne)
          Creates and returns a Term that represents the function that returns twice the value of the argument.
static boolean test(java.io.PrintStream out, boolean isVerbose)
          Execute some operations using base 2 numerals.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

public static final Abstraction ZERO
Term that represents the function that returns "K" if the argument is "0", "F" elsewhere.


HALF

public static final Abstraction HALF
Term that represents the function that returns half the value of the argument.


TWICE0

public static final Abstraction TWICE0
Term that represents the function that returns twice the value of the argument.


TWICE1

public static final Abstraction TWICE1
Term that represents the function that returns twice the value of the argument plus one.


SUCCESSOR

public static final Application SUCCESSOR
Term that represents the function that returns the successor of the value of the argument.


THREE_N_PLUS_R

public static final Application THREE_N_PLUS_R
Term that represents the function g(n, r) = 3 * n + r, with r = 0, 1 or 2.

Constructor Detail

Base2Numerals

public Base2Numerals()
Method Detail

newInt

public static final Abstraction newInt(int n)
Creates and returns a Term that represents an integer.

Parameters:
n - the integer to represent.
Returns:
the base 2 numeral Term for the given integer.
Throws:
java.lang.IllegalArgumentException - if the integer n is negative.

longValue

public static final long longValue(TermReducer termReducer,
                                   Term term)
Returns the long value modulo 2^63 of the given base 2 numeral term.

Parameters:
term - a base 2 numeral Term.
Returns:
the long value modulo 2^63 of the given base 2 numeral term.
Throws:
java.lang.IllegalStateException - if the given Term doesn't represent a base 2 numeral Term.

newTwice

public static final Abstraction newTwice(boolean plusOne)
Creates and returns a Term that represents the function that returns twice the value of the argument.

Formula is : "\t.Z t 0(\r.r p F t)" with p = F if plusOne, K elsewhere.

Parameters:
plusOne - if true then adds one to the function result. The function result becomes 2n+1 in place of 2n.
Returns:
the Twice function of base 2 numeral.

main

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

test

public static boolean test(java.io.PrintStream out,
                           boolean isVerbose)
Execute some operations using base 2 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.