org.algernon.datatype
Class BindingSet
java.lang.Object
org.jatha.dynatype.StandardLispValue
org.jatha.dynatype.StandardLispConsOrNil
org.algernon.datatype.BindingSet
- All Implemented Interfaces:
- Comparable, LispConsOrNil, LispValue
- public class BindingSet
- extends StandardLispConsOrNil
This is a set of BindingLists.
Method Summary |
void |
addList(BindingList newList)
Adds a new list to the binding set. |
LispValue |
bind(LispValue var,
LispValue env,
LispValue term)
|
int |
bindingsCount()
Returns the number of bindings across all binding lists in the set. |
protected static LispValue |
bindingTerm(LispValue binding)
|
protected static LispValue |
bindingVar(LispValue binding)
|
void |
clear()
Removes all entries from the BindingSet. |
protected LispValue |
dereferenceExpression(LispValue term,
LispValue env,
LispValue patEnv)
Follows bindings to a non-variable or unbound variable. |
protected static LispValue |
dereferencePattern(LispValue pattern,
LispValue patEnv)
Follows bindings to a non-variable or unbound variable. |
BindingList |
getEntry(int index)
Return the nth BindingList in the given register, where the topmost
item is entry number zero. |
BindingList |
getRandomBindingList()
Returns a random binding list from the set. |
boolean |
hasSingleBinding(LispValue var)
Returns true if the given variable has one and only one
binding in this binding set. |
boolean |
isEmpty()
Returns true if this binding set contains no bindings. |
Iterator |
iterator()
Returns an iterator over the BindingSet. |
BindingSet |
merge(BindingSet otherSet)
Merges two binding sets and returns a new one. |
LispValue |
pop()
Removes the first BindingList and returns it. |
BindingSet |
push(BindingList newList)
Pushes the new BindingList onto the BindingSet. |
int |
size()
Returns the number of binding lists in this binding set. |
String |
toString()
|
LispValue |
unify(LispValue pattern,
LispValue expression)
Unifies the unbound clause with the bound clauses (data) and
returns a binding list containing the bindings derived from
unification. |
protected LispValue |
unifyAux(LispValue pattern,
LispValue patEnv,
LispValue expression,
LispValue expEnv)
|
BindingSet |
unmerge(LispValue countedVariable)
Takes a merged binding set and undoes the combinatorial merge,
returning a binding set which represents the previous version of the input set
before the merge. |
Methods inherited from class org.jatha.dynatype.StandardLispValue |
abs, acos, add, adjustSpecialCount, append, apply, apropos_print, asin, assoc, atan, atan2, atom, basic_atom, basic_bignump, basic_constantp, basic_floatp, basic_foreignp, basic_functionp, basic_integerp, basic_keywordp, basic_length, basic_macrop, basic_null, basic_numberp, basic_stringp, basic_symbolp, bignump, boundp, car, cdr, ceiling, characterp, clrhash, compareTo, concatenate, consp, constantp, contains, copy_list, copy, cos, cot, csc, degreesToRadians, divide, eighth, elt, eq, eql, equal, equalNumeric, factorial, fboundp, fifth, first, floatp, floor, fourth, funcall, functionp, get_specialCount, gethash, gethash, getLisp, greaterThan, greaterThanOrEqual, hash_table_count, hash_table_rehash_size, hash_table_rehash_threshold, hash_table_size, hash_table_test, hashtablep, integerp, internal_getName, internal_prin1_as_cdr, internal_prin1, internal_princ_as_cdr, internal_princ, internal_print_as_cdr, internal_print, keywordp, last, lessThan, lessThanOrEqual, lisp_null, list, max, member, min, multiply, negate, neql, ninth, nstringCapitalize, nstringDowncase, nstringUpcase, numberp, prin1, princ, print, push, radiansToDegrees, rassoc, reciprocal, remhash, remove, rest, rplaca, rplacd, sec, second, set_special, setf_gethash, setf_symbol_function, setf_symbol_plist, setf_symbol_value, setLisp, setPackage, setq, seventh, sin, sixth, specialP, sqrt, string, stringCapitalize, stringDowncase, stringEndsWith, stringEq, stringEqual, stringGreaterP, stringGreaterThan, stringGreaterThanOrEqual, stringLeftTrim, stringLeftTrim, stringLessP, stringLessThan, stringLessThanOrEqual, stringNeq, stringNotGreaterP, stringNotLessP, stringp, stringRightTrim, stringRightTrim, stringStartsWith, stringTrim, stringTrim, stringUpcase, subst, substring, substring, subtract, symbol_function, symbol_name, symbol_package, symbol_plist, symbol_value, symbolp, tan, tenth, third, toCollection, toJava, toJava, toString, toStringAsCdr_internal, toStringAsCdr, toStringShort, toStringShort, toStringSimple, type_of, typep, zerop |
Methods inherited from interface org.jatha.dynatype.LispValue |
abs, acos, add, adjustSpecialCount, append, apply, apropos_print, asin, assoc, atan, atan2, atom, basic_atom, basic_bignump, basic_constantp, basic_floatp, basic_foreignp, basic_functionp, basic_integerp, basic_keywordp, basic_length, basic_macrop, basic_null, basic_numberp, basic_stringp, basic_symbolp, bignump, boundp, car, cdr, ceiling, characterp, clrhash, compareTo, concatenate, consp, constantp, contains, copy_list, copy, cos, cot, csc, degreesToRadians, divide, eighth, elt, eq, eql, equal, equalNumeric, factorial, fboundp, fifth, first, floatp, floor, fourth, funcall, functionp, get_specialCount, gethash, gethash, getLisp, greaterThan, greaterThanOrEqual, hash_table_count, hash_table_rehash_size, hash_table_rehash_threshold, hash_table_size, hash_table_test, hashtablep, integerp, internal_getName, internal_prin1_as_cdr, internal_prin1, internal_princ_as_cdr, internal_princ, internal_print_as_cdr, internal_print, keywordp, last, lessThan, lessThanOrEqual, lisp_null, list, max, member, min, multiply, negate, neql, ninth, nstringCapitalize, nstringDowncase, nstringUpcase, numberp, prin1, princ, print, push, radiansToDegrees, rassoc, reciprocal, remhash, remove, rest, rplaca, rplacd, sec, second, set_special, setf_gethash, setf_symbol_function, setf_symbol_plist, setf_symbol_value, setLisp, setPackage, setq, seventh, sin, sixth, specialP, sqrt, string, stringCapitalize, stringDowncase, stringEndsWith, stringEq, stringEqual, stringGreaterP, stringGreaterThan, stringGreaterThanOrEqual, stringLeftTrim, stringLeftTrim, stringLessP, stringLessThan, stringLessThanOrEqual, stringNeq, stringNotGreaterP, stringNotLessP, stringp, stringRightTrim, stringRightTrim, stringStartsWith, stringTrim, stringTrim, stringUpcase, subst, substring, substring, subtract, symbol_function, symbol_name, symbol_package, symbol_plist, symbol_value, symbolp, tan, tenth, third, toCollection, toJava, toJava, toString, toStringAsCdr_internal, toStringAsCdr, toStringShort, toStringShort, toStringSimple, type_of, typep, zerop |
FAILED
public LispValue FAILED
f_bindings
protected ArrayList f_bindings
f_algy
private Algernon f_algy
BindingSet
public BindingSet(Algernon algy)
- Create a new BindingSet.
BindingSet
public BindingSet(Algernon algy,
BindingList bl)
- Create a new BindingSet containing one binding list.
toString
public String toString()
addList
public void addList(BindingList newList)
- Adds a new list to the binding set.
getEntry
public BindingList getEntry(int index)
- Return the nth BindingList in the given register, where the topmost
item is entry number zero.
If the index given is greater than the number of items
in the register, null is returned.
This value can always be coerced to BindingList.
merge
public BindingSet merge(BindingSet otherSet)
- Merges two binding sets and returns a new one.
unify
public LispValue unify(LispValue pattern,
LispValue expression)
- Unifies the unbound clause with the bound clauses (data) and
returns a binding list containing the bindings derived from
unification.
Returns the symbol :FAILED if the bindings failed.
unifyAux
protected LispValue unifyAux(LispValue pattern,
LispValue patEnv,
LispValue expression,
LispValue expEnv)
bind
public LispValue bind(LispValue var,
LispValue env,
LispValue term)
dereferenceExpression
protected LispValue dereferenceExpression(LispValue term,
LispValue env,
LispValue patEnv)
- Follows bindings to a non-variable or unbound variable. Returns
the final term and its environment.
dereferencePattern
protected static LispValue dereferencePattern(LispValue pattern,
LispValue patEnv)
- Follows bindings to a non-variable or unbound variable. Returns
the final term. (We know that the term's environment is still
*PAT-ENV*, if it is a variable, because no variable in *PAT-ENV* is
ever bound to a variable in *EXP-ENV*.)
bindingTerm
protected static LispValue bindingTerm(LispValue binding)
bindingVar
protected static LispValue bindingVar(LispValue binding)
getRandomBindingList
public BindingList getRandomBindingList()
- Returns a random binding list from the set.
pop
public LispValue pop()
- Removes the first BindingList and returns it.
The value can be coerced to BindingList.
Returns null if there are not enough BindingLists.
hasSingleBinding
public boolean hasSingleBinding(LispValue var)
- Returns true if the given variable has one and only one
binding in this binding set.
push
public BindingSet push(BindingList newList)
- Pushes the new BindingList onto the BindingSet.
size
public int size()
- Returns the number of binding lists in this binding set.
clear
public void clear()
- Removes all entries from the BindingSet.
iterator
public Iterator iterator()
- Returns an iterator over the BindingSet. Each
element of the iteration is a BindingList.
isEmpty
public boolean isEmpty()
- Returns true if this binding set contains no bindings.
bindingsCount
public int bindingsCount()
- Returns the number of bindings across all binding lists in the set.
unmerge
public BindingSet unmerge(LispValue countedVariable)
- Takes a merged binding set and undoes the combinatorial merge,
returning a binding set which represents the previous version of the input set
before the merge.
Destructively modifies the list.
- Parameters:
countedVariable
-