public class Var extends Term
Term
,
Serialized FormConstructor and Description |
---|
Var()
Creates an anonymous variable
This is equivalent to build a variable with name _
|
Var(String n)
Creates a variable identified by a name.
|
Modifier and Type | Method and Description |
---|---|
Term |
copy(AbstractMap vMap,
AbstractMap substMap)
Gets a copy of this variable.
|
Term |
copy(AbstractMap vMap,
int idExecCtx)
Gets a copy of this variable.
|
void |
free()
De-unify the variable
|
static void |
free(List varsUnified)
De-unify the variables of list
|
String |
getName()
Gets the name of the variable
|
String |
getOriginalName()
Gets the name of the variable
|
Term |
getTerm()
Gets the term which is referred by the variable.
|
boolean |
isAnonymous()
Tests if this variable is ANY
|
boolean |
isAtom()
is this term a prolog (alphanumeric) atom?
|
boolean |
isAtomic()
is this term a constant prolog term?
|
boolean |
isBound()
Tests if this variable is bound
|
boolean |
isCompound()
is this term a prolog compound term?
|
boolean |
isEmptyList()
is this term a null term?
|
boolean |
isEqual(Prolog mediator,
Term t)
Tests if this term is (logically) equal to another
|
boolean |
isGreater(Prolog mediator,
Term t)
Gets a copy of this variable
|
boolean |
isGround()
is this term a ground term?
|
boolean |
isList()
is this term a prolog list?
|
boolean |
isNumber()
is this term a prolog numeric term?
|
boolean |
isStruct()
is this term a struct?
|
boolean |
isVar()
is this term a variable?
|
long |
resolveTerm(long count)
Resolve the occurence of variables in a Term
|
String |
toString()
Gets the string representation of this variable.
|
String |
toStringFlattened()
Gets the string representation of this variable, providing
the string representation of the linked term in the case of
bound variable
|
boolean |
unify(Prolog mediator,
List vl1,
List vl2,
Term t)
var unification.
|
copyGoal, copyResult, createTerm, createTerm, equals, getIterator, iteratedGoalTerm, match, parse, parse, resolveTerm, unify
public Var(String n) throws InvalidTermException
n
- is the nameInvalidTermException
- if n is not a valid namepublic Var()
public Term copy(AbstractMap vMap, int idExecCtx)
public Term copy(AbstractMap vMap, AbstractMap substMap)
public static void free(List varsUnified)
public String getName()
public String getOriginalName()
public Term getTerm()
public boolean isNumber()
Term
public boolean isStruct()
Term
public boolean isVar()
Term
public boolean isEmptyList()
Term
isEmptyList
in class Term
public boolean isAtomic()
Term
public boolean isCompound()
Term
isCompound
in class Term
public boolean isAtom()
Term
public boolean isList()
Term
public boolean isGround()
Term
public boolean isAnonymous()
public boolean isBound()
public long resolveTerm(long count)
resolveTerm
in class Term
count
- new starting time count for resolving processpublic boolean unify(Prolog mediator, List vl1, List vl2, Term t)
First, verify the Term eventually already unified with the same Var if the Term exist, unify var with that term, in order to handle situation as (A = p(X) , A = p(1)) which must produce X/1.
If instead the var is not already unified, then:
if the Term is a var bound to X, then try unification with X so for example if A=1, B=A then B is unified to 1 and not to A (note that it's coherent with chronological backtracking: the eventually backtracked A unification is always after backtracking of B unification.
if are the same Var, unification must succeed, but without any new bindings (to avoid cycles for extends in A = B, B = A)
if the term is a number, then it's a success and new link is created (retractable by means of a code)
if the term is a compound, then occur check test is executed: the var must not appear in the compound ( avoid X=p(X), or p(X,X)=p(Y,f(Y)) ); if occur check is ok then it's success and a new link is created (retractable by a code)
public boolean isEqual(Prolog mediator, Term t)
Term
public String toString()
public String toStringFlattened()
Copyright © 2015. All rights reserved.