org.fun4j
Class Cons

java.lang.Object
  extended by org.fun4j.Cons

public class Cons
extends java.lang.Object

Simple Binary Tree. This class represents a Lisp cons object. All Lisp data structures are internally represented as conses.

Author:
Thomas Mahler

Constructor Summary
Cons(java.lang.Object head, java.lang.Object tail)
          constructs a new Cons based on head and tail
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.Object getHd()
          returns the head of a the Cons object
 java.lang.Object getTl()
          returns the tail of a Cons object.
 java.lang.String prettyPrint()
          simple prettyprinting for Cons objects.
 java.lang.String prettyPrint1(int depth, int length, int indent)
          pretty print a Cons respecting printdepth and printlength
static java.math.BigInteger printdepth(java.math.BigInteger newValue)
          set the printdepth for list printing.
static java.lang.Integer printdepth(java.lang.Integer newValue)
          set the printdepth for list printing.
static java.math.BigInteger printlength(java.math.BigInteger newValue)
          set the printlength for list printing.
static java.lang.Integer printlength(java.lang.Integer newValue)
          set the printlength for list printing.
 void setHd(java.lang.Object hd)
          sets the head of this Cons object
 void setTl(java.lang.Object tl)
          sets the tail of a Cons object
 java.lang.String toString()
          
 java.lang.String toString1(int depth, int length)
          print out a Cons respecting printdepth and printlength
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cons

public Cons(java.lang.Object head,
            java.lang.Object tail)
constructs a new Cons based on head and tail

Parameters:
head - the head Object
tail - the tail Object
Method Detail

getHd

public java.lang.Object getHd()
returns the head of a the Cons object

Returns:
the head

setHd

public void setHd(java.lang.Object hd)
sets the head of this Cons object

Parameters:
hd - the new head element

getTl

public java.lang.Object getTl()
returns the tail of a Cons object.

Returns:
the tail

setTl

public void setTl(java.lang.Object tl)
sets the tail of a Cons object

Parameters:
tl - the tail to set

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

printdepth

public static java.lang.Integer printdepth(java.lang.Integer newValue)
set the printdepth for list printing. Useful to avoid endless loops when printing circular Cons objects

Parameters:
newValue - the new value
Returns:
the old value

printlength

public static java.lang.Integer printlength(java.lang.Integer newValue)
set the printlength for list printing.

Parameters:
newValue - the new value
Returns:
the old value

printdepth

public static java.math.BigInteger printdepth(java.math.BigInteger newValue)
set the printdepth for list printing. Useful to avoid endless loops when printing circular Cons objects

Parameters:
newValue - the new value
Returns:
the old value

printlength

public static java.math.BigInteger printlength(java.math.BigInteger newValue)
set the printlength for list printing.

Parameters:
newValue - the new value
Returns:
the old value

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

toString1

public java.lang.String toString1(int depth,
                                  int length)
print out a Cons respecting printdepth and printlength

Parameters:
depth -
length -
Returns:
the String representation of the Cons

prettyPrint

public java.lang.String prettyPrint()
simple prettyprinting for Cons objects.

Returns:
the String representation

prettyPrint1

public java.lang.String prettyPrint1(int depth,
                                     int length,
                                     int indent)
pretty print a Cons respecting printdepth and printlength

Parameters:
depth -
length -
indent -
Returns:
the String representation