org.jscience.computing.ai.planning
Class List

java.lang.Object
  extended by org.jscience.computing.ai.planning.CompileTimeObject
      extended by org.jscience.computing.ai.planning.List

public class List
extends CompileTimeObject

Each list, both at compile time and at run time, is an instance of this class. Lists are represented the same way they are represented in LISP, i.e., as a structure consisting of two CONS, where each CONS can be a list itself.


Constructor Summary
List(Term headIn, Term tailIn)
          To initialize this list.
 
Method Summary
 List append(Term t)
          To append another term to the end of this list.
 List bindList(Term[] binding)
          To apply a given binding to this list.
 boolean equals(List t)
          Whether or not another list is equivalent to the this list.
 boolean findUnifierList(List l, Term[] binding)
          Find a unifier that will bind this list to another given list.
 Term getHead()
          To get the head of this list, a term.
 List getRest()
          To get the tail of this list as another list, assuming that the tail is indeed a list.
 Term getTail()
          To get the tail of this list, a term.
 boolean isGroundList()
          Is this list ground (i.e., has no variables)?
static List MakeList(java.util.LinkedList listIn)
          This function gets a LinkedList of terms as input and returns a list the elements of which are the terms in the input LinkedList in the reverse order.
 void print()
          This function is used to print this list.
 java.lang.String toCode()
          This function is used at compile time to produce Java code that when run, will create this list.
 java.lang.String toString()
          This function is used to print the value of this list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

List

public List(Term headIn,
            Term tailIn)
To initialize this list.

Parameters:
headIn - the term to be the head of this list.
tailIn - the term to be the tail of this list.
Method Detail

append

public List append(Term t)
To append another term to the end of this list. Note that this function is destructive, i.e., it appends the given term to this list, and not a copy of it.

Parameters:
t - the term to be appended to this list.
Returns:
the result of appending.

bindList

public List bindList(Term[] binding)
To apply a given binding to this list. Note that this function does NOT change this list, rather, it creates a new list which is the result of binding.

Parameters:
binding - an array of terms, indexed by the integers associated with variable symbols.
Returns:
the result of binding.

equals

public boolean equals(List t)
Whether or not another list is equivalent to the this list.

Parameters:
t - the list being compared to the this list.
Returns:
true if the two lists are equal, false otherwise.

findUnifierList

public boolean findUnifierList(List l,
                               Term[] binding)
Find a unifier that will bind this list to another given list.

Parameters:
l - the list with which we are finding a unifier.
binding - the unifier to be returned.
Returns:
false if the two lists can not be unified, true otherwise.

getHead

public Term getHead()
To get the head of this list, a term.

Returns:
the head of this list, a term.

getRest

public List getRest()
To get the tail of this list as another list, assuming that the tail is indeed a list.

Returns:
the tail of this list as another list.

getTail

public Term getTail()
To get the tail of this list, a term.

Returns:
the tail of this list, a term.

isGroundList

public boolean isGroundList()
Is this list ground (i.e., has no variables)?

Returns:
true if this list is ground, false otherwise.

MakeList

public static List MakeList(java.util.LinkedList listIn)
This function gets a LinkedList of terms as input and returns a list the elements of which are the terms in the input LinkedList in the reverse order.

Parameters:
listIn - the input LinkedList.
Returns:
the resulting list.

print

public void print()
This function is used to print this list.


toCode

public java.lang.String toCode()
This function is used at compile time to produce Java code that when run, will create this list.

Specified by:
toCode in class CompileTimeObject
Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
This function is used to print the value of this list.

Overrides:
toString in class java.lang.Object
Returns:
the printable String that shows the value of this list.