Tuple
A Recursive structure with functor , and arity 2, i.e. the classic Prolog conjunction (A, B). Tuples of more than two terms are represented by right-nesting: (A, B, C) is [left]=A, [right]=(B, C). This is the same functor Prolog uses for clause bodies with multiple goals — that is why Clause.body and Rule.of fold multi-goal bodies into a Tuple under the hood.
Since a two-argument Struct with functor , is structurally identical to a Tuple, Struct.of and wrapIfNeeded automatically return a Tuple whenever that shape arises; there is normally no need to distinguish a plain , /2 Struct from a Tuple by hand.
Properties
Sequence of arguments of this Struct.
Checks whether the current term is a constant, i.e., either an atom or a number. This method is guaranteed to return true if and only if the current term is an instance of Constant.
Checks whether the current term is a directive. This method is guaranteed to return true if and only if the current term is an instance of Directive.
Checks whether the current term is an empty logic block. This method is guaranteed to return true if and only if the current term is an instance of EmptyBlock.
Checks whether the current term is an empty logic list. This method is guaranteed to return true if and only if the current term is an instance of EmptyList.
Checks whether the current term is the either the fail atom or the false atom. This method is guaranteed to return true if and only if the current term is an instance of Truth and its Truth.value is "fail" or "false".
Returns true if and only if functor matches Struct.WELL_FORMED_FUNCTOR_PATTERN.
Checks whether the current term is an indicator. This method is guaranteed to return true if and only if the current term is an instance of Indicator.
Checks whether the current term is a recursive structure, i.e., a list, a tuple, or a block. This method is guaranteed to return true if and only if the current term is an instance of Recursive.
Checks whether the current term is the true atom. This method is guaranteed to return true if and only if the current term is an instance of Truth and its Truth.value is "true".
The elements of this structure, unfolded eagerly into an Array.
The elements of this structure, unfolded eagerly into a List.
The elements of this structure, unfolded lazily, in order. Same as unfold.
The sequence of Variables directly or indirectly contained in the current object. Variables are lazily returned in a non-deterministic order. Notice that no occurrence-check is performed. Thus, if a Term contains the same Variable twice or more times, then the variables sequence may contain as many occurrences of that Variable
Functions
Lets the provided TermVisitor navigate the current term and build an object of type T. Such an object is then returned as a result by this method.
Applies a Substitution to the current object, producing a new instance of T which differs from the current object because variables are replaced by their values, according to the binding carried by substitution.
Applies one or more Substitutions to the current object, producing a new instance of T which differs from the current one because variables are replaced by their values, according to the binding carried by the provided substitutions.
Casts the current Term to EmptyBlock, if possible, or returns null otherwise
Casts the current Term to EmptyBlock, if possible
Checks whether another term is equals to the current one or not, by explicitly letting the client decide whether to rely or not on Varriables complete names for checking equality among two Variables. If useVarCompleteName is true, Variables are compared through their Var.completeName property. Otherwise, they are compared through their Var.name property. Other sorts of terms are compared as Term.equals(Any?).
Returns a fresh copy of this object, that is, an instance of T which is equal to the current one in any aspect, except for variables directly or indirectly contained into this object, which are refreshed. This means the method could return this object itself, if no variable is present, or a new object with freshly generated variables.
Returns a fresh copy of this object, similarly to freshCopy(), possibly reusing variables from the provided scope, if any
This is an alias for apply aimed at supporting a square-brackets syntax for substitutions applications in Kotlin programs. It lets programmers write object[substitution] instead of object.apply(substitution). It applies one or more Substitutions to the current object, producing a new Term which differs from the current one because variables are replaced by their values, according to the binding carried by the provided substitutions.
Alias for getArgAt. In Kotlin, this method enables the syntax struct[index].
Creates a novel Struct which is a copy of the current one, expect that is has a different functor.
Checks whether another term is structurally equals to the current one or not. Structural equivalence is a looser type of equivalence (w.r.t. term equivalence) where:
Lazily unfolds this structure's elements into a Sequence. Same as unfoldedSequence.
Lazily unfolds this structure's elements. Same as unfoldedSequence.