com.ugos.JIProlog.engine
Class JIPCons

java.lang.Object
  |
  +--com.ugos.JIProlog.engine.JIPTerm
        |
        +--com.ugos.JIProlog.engine.JIPCons
All Implemented Interfaces:
com.ugos.JIProlog.engine.Clearable, java.lang.Cloneable, java.io.Serializable

public class JIPCons
extends JIPTerm

JIPList wraps a prolog cons (a cons is composed by a set of terms separated by comma eventually enclosed in parenthesis: a,b,c or (a,b,c,).

Version:
2.0
Author:
Ugo Chirico 2002
Home Page: http://www.ugosweb.com/jiprolog
See Also:
JIPTerm, Serialized Form

Field Summary
static JIPCons NIL
          Empty cons or nil
 
Method Summary
static JIPCons append(JIPCons cons1, JIPCons cons2)
          Returns a new JIPCons object by appending cons2 to cons1
static JIPCons create(JIPTerm head, JIPTerm tail)
          Creates a new cons object
 JIPTerm getHead()
          Returns the head of this JIPCons object
 int getHeight()
          Returns the number of elements in this cons object.
 JIPTerm getNth(int n)
          Returns the nth term in this cons.
 JIPTerm getTail()
          Returns the tail of this JIPCons object
 boolean isNIL()
          Returns true if this cons is nil.
 JIPCons reverse()
          Returns a new JIPCons object by reversing this JIPCons object
 
Methods inherited from class com.ugos.JIProlog.engine.JIPTerm
clear, clone, getVariables, getVariablesTable, toString, toString, toStringq, unifiable, unify
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NIL

public static final JIPCons NIL
Empty cons or nil

Method Detail

create

public static final JIPCons create(JIPTerm head,
                                   JIPTerm tail)
Creates a new cons object

Parameters:
head - the head of the cons
tail - the tail the cons
Returns:
new JIPCons object
See Also:
JIPTerm

append

public static final JIPCons append(JIPCons cons1,
                                   JIPCons cons2)
Returns a new JIPCons object by appending cons2 to cons1

Parameters:
cons1 - first cons
cons2 - cons to append at the end of the first one.
Returns:
new JIPCons object by appending cons1 and cons2

reverse

public final JIPCons reverse()
Returns a new JIPCons object by reversing this JIPCons object

Returns:
new JIPCons object by reversing this JIPCons object

getHead

public final JIPTerm getHead()
Returns the head of this JIPCons object

Returns:
head of this JIPCons
See Also:
JIPTerm

getTail

public final JIPTerm getTail()
Returns the tail of this JIPCons object

Returns:
tail of this JIPCons object
See Also:
JIPTerm

getNth

public final JIPTerm getNth(int n)
Returns the nth term in this cons.
Raises ArrayIndexOutOfBound if the parameter is out of bound

Parameters:
n - index ot the term to extract
Returns:
the nth term in this cons.
See Also:
JIPTerm

isNIL

public final boolean isNIL()
Returns true if this cons is nil.


getHeight

public final int getHeight()
Returns the number of elements in this cons object.

Returns:
the number of elements in this cons object.