Class Struct
- java.lang.Object
-
- alice.tuprolog.Term
-
- alice.tuprolog.Struct
-
- All Implemented Interfaces:
java.io.Serializable
public class Struct extends Term
Struct class represents both compound prolog term and atom term (considered as 0-arity compound).- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class alice.tuprolog.Term
Term.Comparison
-
-
Constructor Summary
Constructors Constructor Description Struct()
Deprecated.Struct(Term... argList)
Deprecated.Struct(Term h, Term t)
Deprecated.Struct(java.lang.String f, Term... argList)
Deprecated.Struct(java.util.Collection<? extends Term> terms)
Deprecated.Struct(java.util.Iterator<? extends Term> i)
Deprecated.Struct(java.util.stream.Stream<? extends Term> stream)
Deprecated.
-
Method Summary
Modifier and Type Method Description <T> T
accept(TermVisitor<T> tv)
Visitor patternvoid
append(Term t)
Appends an element to this structure supposed to be a liststatic Struct
atom(java.lang.String atom)
static Struct
cons(Term head, Term tail)
Struct
copy()
Term
copyAndRetainFreeVar(java.util.Map<Var,Var> vMap, int idExecCtx)
static Struct
cut()
static Struct
directive(Term body)
static Struct
emptyList()
static Struct
emptySet()
boolean
equals(Term other, java.util.EnumSet<Term.Comparison> comparison)
boolean
equals(java.lang.Object t)
Tests for the equality of two object termsvoid
free()
dummy methodTerm
getArg(int index)
Gets the i-th element of this structureStruct
getArg(java.lang.String name)
Gets an argument inside this structure, given its nameTerm[]
getArgs()
int
getArity()
Gets the number of elements of this structurejava.lang.String
getName()
Gets the functor name of this structurePrimitiveInfo
getPrimitive()
Get primitive behaviour associated at structureTerm
getTerm()
Gets the actual term referred by this Term.Term
getTerm(int index)
Gets the i-th element of this structureint
hashCode()
boolean
isAtom()
is this term a prolog (alphanumeric) atom?boolean
isAtomic()
is this term a constant prolog term?boolean
isClause()
Check is this struct is clause or directiveboolean
isCompound()
is this term a prolog compound term?boolean
isCons()
boolean
isEmptyList()
is this term a null term?boolean
isEmptySet()
boolean
isFunctorAtomic()
boolean
isGreater(Term t)
Test if a term is greater than otherboolean
isGround()
is this term a ground term?boolean
isList()
is this term a prolog list?boolean
isNumber()
Deprecated.boolean
isPrimitive()
Check if this term is a primitive structboolean
isSet()
boolean
isStruct()
Deprecated.boolean
isTuple()
boolean
isVar()
Deprecated.Term
iteratedGoalTerm()
The iterated-goal term G of a term T is a term defined recursively as follows: if T unifies with ^(_, Goal) then G is the iterated-goal term of Goal else G is Tstatic Struct
list(Term... terms)
static Struct
list(Term[] items, Term last)
static Struct
list(java.lang.Iterable<? extends Term> terms)
static Struct
list(java.lang.Iterable<? extends Term> items, Term last)
static Struct
list(java.util.Iterator<? extends Term> terms)
static Struct
list(java.util.Iterator<? extends Term> items, Term last)
static Struct
list(java.util.stream.Stream<? extends Term> terms)
static Struct
list(java.util.stream.Stream<? extends Term> items, Term last)
Term
listHead()
Gets the head of this structure, which is supposed to be a list.java.util.Iterator<? extends Term>
listIterator()
Gets an iterator on the elements of this structure, which is supposed to be a list.int
listSize()
Gets the number of elements of this structure, which is supposed to be a list.java.util.stream.Stream<? extends Term>
listStream()
Struct
listTail()
Gets the tail of this structure, which is supposed to be a list.static Struct
of(java.lang.String functor, Term[] terms)
static Struct
of(java.lang.String functor, Term term1, Term... terms)
static Struct
rule(Term head, Term body)
static Struct
set(Term term)
static Struct
set(Term term1, Term term2, Term terms)
static Struct
set(java.lang.Iterable<? extends Term> terms)
static Struct
set(java.util.Collection<? extends Term> terms)
static Struct
set(java.util.Iterator<? extends Term> terms)
static Struct
set(java.util.stream.Stream<? extends Term> terms)
void
setArg(int index, Term argument)
Sets the i-th element of this structurejava.lang.String
toString()
Gets the string representation of this structurestatic Struct
truth(boolean value)
static Struct
tuple(Term term1, Term term2, Term... terms)
static Struct
tuple(java.lang.Iterable<? extends Term> terms)
static Struct
tuple(java.util.Collection<? extends Term> terms)
static Struct
tuple(java.util.Iterator<? extends Term> terms)
static Struct
tuple(java.util.List<? extends Term> terms)
static Struct
tuple(java.util.stream.Stream<? extends Term> terms)
java.util.Iterator<? extends Term>
unfoldedListIterator()
java.util.stream.Stream<? extends Term>
unfoldedListStream()
java.util.Iterator<? extends Term>
unfoldedSetIterator()
java.util.stream.Stream<? extends Term>
unfoldedSetStream()
java.util.Iterator<? extends Term>
unfoldedTupleIterator()
java.util.stream.Stream<? extends Term>
unfoldedTupleStream()
-
Methods inherited from class alice.tuprolog.Term
castTo, copyGoal, copyResult, createTerm, createTerm, equals, getIterator, isEqual, lexicographicComparator, match, match, parse, parse, resolveTerm, unify
-
-
-
-
Constructor Detail
-
Struct
@Deprecated public Struct(java.lang.String f, Term... argList)
Deprecated.Builds a compound, with an array of arguments
-
Struct
@Deprecated public Struct()
Deprecated.Builds a structure representing an emptyWithStandardOperators list
-
Struct
@Deprecated public Struct(java.util.Collection<? extends Term> terms)
Deprecated.
-
Struct
@Deprecated public Struct(Term... argList)
Deprecated.Builds a list specifying the elements
-
Struct
@Deprecated public Struct(java.util.stream.Stream<? extends Term> stream)
Deprecated.
-
Struct
@Deprecated public Struct(java.util.Iterator<? extends Term> i)
Deprecated.
-
-
Method Detail
-
emptySet
public static Struct emptySet()
-
cut
public static Struct cut()
-
truth
public static Struct truth(boolean value)
-
atom
public static Struct atom(java.lang.String atom)
-
emptyList
public static Struct emptyList()
-
getArity
public int getArity()
Gets the number of elements of this structure
-
getName
public java.lang.String getName()
Gets the functor name of this structure
-
getArg
public Term getArg(int index)
Gets the i-th element of this structureNo bound check is done
-
setArg
public void setArg(int index, Term argument)
Sets the i-th element of this structure(Only for internal service)
-
getTerm
public Term getTerm(int index)
Gets the i-th element of this structureNo bound check is done. It is equivalent to
getArg(index).getTerm()
-
isNumber
@Deprecated public boolean isNumber()
Deprecated.is this term a prolog numeric term?
-
isStruct
@Deprecated public boolean isStruct()
Deprecated.is this term a struct
-
isVar
@Deprecated public boolean isVar()
Deprecated.is this term a variable
-
isAtomic
public boolean isAtomic()
Description copied from class:Term
is this term a constant prolog term?
-
isCompound
public boolean isCompound()
Description copied from class:Term
is this term a prolog compound term?- Overrides:
isCompound
in classTerm
-
isAtom
public boolean isAtom()
Description copied from class:Term
is this term a prolog (alphanumeric) atom?
-
isGround
public boolean isGround()
Description copied from class:Term
is this term a ground term?
-
equals
public boolean equals(java.lang.Object t)
Description copied from class:Term
Tests for the equality of two object terms
-
equals
public boolean equals(Term other, java.util.EnumSet<Term.Comparison> comparison)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
isClause
public boolean isClause()
Check is this struct is clause or directive
-
getTerm
public Term getTerm()
Description copied from class:Term
Gets the actual term referred by this Term. if the Term is a bound variable, the method gets the Term linked to the variable
-
getArg
public Struct getArg(java.lang.String name)
Gets an argument inside this structure, given its name- Parameters:
name
- name of the structure- Returns:
- the argument or null if not found
-
isGreater
public boolean isGreater(Term t)
Test if a term is greater than other
-
copyAndRetainFreeVar
public Term copyAndRetainFreeVar(java.util.Map<Var,Var> vMap, int idExecCtx)
- Specified by:
copyAndRetainFreeVar
in classTerm
-
isList
public boolean isList()
Description copied from class:Term
is this term a prolog list?
-
isEmptyList
public boolean isEmptyList()
Description copied from class:Term
is this term a null term?- Overrides:
isEmptyList
in classTerm
-
isEmptySet
public boolean isEmptySet()
- Overrides:
isEmptySet
in classTerm
-
listHead
public Term listHead()
Gets the head of this structure, which is supposed to be a list.Gets the head of this structure, which is supposed to be a list. If the callee structure is not a list, throws an
UnsupportedOperationException
-
listTail
public Struct listTail()
Gets the tail of this structure, which is supposed to be a list.Gets the tail of this structure, which is supposed to be a list. If the callee structure is not a list, throws an
UnsupportedOperationException
-
listSize
public int listSize()
Gets the number of elements of this structure, which is supposed to be a list.Gets the number of elements of this structure, which is supposed to be a list. If the callee structure is not a list, throws an
UnsupportedOperationException
-
listIterator
public java.util.Iterator<? extends Term> listIterator()
Gets an iterator on the elements of this structure, which is supposed to be a list.Gets an iterator on the elements of this structure, which is supposed to be a list. If the callee structure is not a list, throws an
UnsupportedOperationException
-
unfoldedListIterator
public java.util.Iterator<? extends Term> unfoldedListIterator()
-
unfoldedTupleIterator
public java.util.Iterator<? extends Term> unfoldedTupleIterator()
-
unfoldedSetIterator
public java.util.Iterator<? extends Term> unfoldedSetIterator()
-
listStream
public java.util.stream.Stream<? extends Term> listStream()
-
unfoldedListStream
public java.util.stream.Stream<? extends Term> unfoldedListStream()
-
unfoldedTupleStream
public java.util.stream.Stream<? extends Term> unfoldedTupleStream()
-
unfoldedSetStream
public java.util.stream.Stream<? extends Term> unfoldedSetStream()
-
append
public void append(Term t)
Appends an element to this structure supposed to be a list
-
getPrimitive
public PrimitiveInfo getPrimitive()
Get primitive behaviour associated at structure
-
isPrimitive
public boolean isPrimitive()
Check if this term is a primitive struct
-
isFunctorAtomic
public boolean isFunctorAtomic()
-
toString
public java.lang.String toString()
Gets the string representation of this structureSpecific representations are provided for lists and atoms. Names starting with upper case letter are enclosed in apices.
- Overrides:
toString
in classjava.lang.Object
-
iteratedGoalTerm
public Term iteratedGoalTerm()
Description copied from class:Term
The iterated-goal term G of a term T is a term defined recursively as follows:- if T unifies with ^(_, Goal) then G is the iterated-goal term of Goal
- else G is T
- Overrides:
iteratedGoalTerm
in classTerm
-
accept
public <T> T accept(TermVisitor<T> tv)
Description copied from class:Term
Visitor pattern
-
getArgs
public Term[] getArgs()
-
-