Class Expression

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended byExpression
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable, Unifiable

class Expression
extends java.util.ArrayList
implements java.util.List, Unifiable

Expressions are ordered sequences of Symbols, Variables, and sub-Expressions (i.e., Unifiables).


Nested Class Summary
 
Nested classes inherited from class java.util.AbstractList
 
Field Summary
 
Fields inherited from class java.util.ArrayList
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
(package private) Expression()
           
 
Method Summary
 boolean add(java.lang.Object x)
          Adds the given Unifiable to this Expression (at the end).
 Unifiable copyWithBindings(BindingSet bindings)
          Returns a new Expression which is a copy of this one with the given bindings applied.
 java.lang.String toString()
          Returns the printable representation of this Expression as a String (using Lisp list syntax).
 boolean unifyWith(Unifiable other, BindingSet bindings)
          Try to unify this Expression with another Unifiable.
 
Methods inherited from class java.util.ArrayList
add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 

Constructor Detail

Expression

Expression()
Method Detail

add

public boolean add(java.lang.Object x)
Adds the given Unifiable to this Expression (at the end). We override our parent's method for this operation in order to ensure that only Unifiables are added to Expressions. We will throw a ClassCastException if the given object is not Unifiable. This is better than having it come up later when we try to unify the Expression.

Specified by:
add in interface java.util.List

toString

public java.lang.String toString()
Returns the printable representation of this Expression as a String (using Lisp list syntax).


unifyWith

public boolean unifyWith(Unifiable other,
                         BindingSet bindings)
Try to unify this Expression with another Unifiable. Two Expressions unify if their respective components unify.

Specified by:
unifyWith in interface Unifiable

copyWithBindings

public Unifiable copyWithBindings(BindingSet bindings)
Returns a new Expression which is a copy of this one with the given bindings applied. This just means traversing the elements of the Expression and recursively calling copyWithBindings().

Specified by:
copyWithBindings in interface Unifiable