public class Compound extends Term
new Compound("f", new Term[] { new Atom("a") })Note the use of the "anonymous array" notation to denote the arguments (an anonymous array of Term).
Util.textToTerm("f(a)")The arity of a Compound is the quantity of its arguments. Once constructed, neither the name nor the arity of a Compound can be altered. An argument of a Compound can be replaced with the setArg() method.
Copyright (C) 1998 Fred Dushin
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library Public License for more details.
Modifier and Type | Field and Description |
---|---|
protected Term[] |
args
the arguments of this Compound
|
protected java.lang.String |
name
the name of this Compound
|
Modifier | Constructor and Description |
---|---|
|
Compound(java.lang.String name)
Creates a Compound with name and no args.
|
protected |
Compound(java.lang.String name,
int arity)
Creates a Compound with name and arity.
|
|
Compound(java.lang.String name,
Term[] args)
Creates a Compound with name and args.
|
Modifier and Type | Method and Description |
---|---|
Term |
arg(int i)
Returns the ith argument (counting from 1) of this Compound; throws an ArrayIndexOutOfBoundsException if i is inappropriate.
|
Term[] |
args()
Returns the arguments of this Compound (1..arity) of this Compound as an array[0..arity-1] of Term.
|
int |
arity()
Returns the arity (1+) of this Compound.
|
boolean |
equals(java.lang.Object obj)
Two Compounds are equal if they are identical (same object) or their names and arities are equal and their respective arguments are equal.
|
protected void |
getSubst(java.util.Map<java.lang.String,Term> varnames_to_Terms,
java.util.Map<term_t,Variable> vars_to_Vars)
Nothing needs to be done except to pass the buck to this Compound's args.
|
boolean |
hasFunctor(java.lang.String name,
int arity)
Tests whether this Compound's functor has (String) 'name' and 'arity'.
|
boolean |
isJFalse()
whether this Term is a 'jboolean' structure denoting Java's false, i.e.
|
boolean |
isJNull()
whether this Term is a 'jnull' structure, i.e.
|
boolean |
isJObject()
whether this Term is a 'jobject' structure, i.e.
|
boolean |
isJRef()
whether this Term is a 'jref' structure, i.e.
|
boolean |
isJTrue()
whether this Term is a 'jboolean' structure denoting Java's true, i.e.
|
boolean |
isJVoid()
whether this Term is a 'jvoid' structure, i.e.
|
boolean |
isListPair()
whether this Term denotes (syntax-specifically) a list cell
|
java.lang.Object |
jrefToObject() |
java.lang.String |
name()
the name (unquoted) of this Compound
|
protected void |
put(java.util.Map<java.lang.String,term_t> varnames_to_vars,
term_t term)
To put a Compound in a term, we create a sequence of term_t references from the Term.terms_to_term_ts() method, and then use the Prolog.cons_functor_v() method to create a Prolog compound term.
|
void |
setArg(int i,
Term arg)
Sets the i-th (from 1) arg of this Compound to the given Term instance.
|
java.lang.String |
toString()
a prefix functional representation of a Compound of the form name(arg1,...), where 'name' is quoted iff necessary (to be valid Prolog soutce text) and each argument is represented according to
its toString() method.
|
int |
type()
the type of this term, as jpl.fli.Prolog.COMPOUND
|
java.lang.String |
typeName()
the name of the type of this term, as "Compound"
|
atomType, bigValue, doubleValue, floatValue, getSubsts, getTerm, getTerm, hasFunctor, hasFunctor, intValue, isAtom, isBigInteger, isCompound, isFloat, isInteger, isListNil, isVariable, listLength, longValue, objectToJRef, put, putParams, putParams, putParams1, putParams2, putTerm, putTerms, terms_equals, toString, toTermArray
protected final Term[] args
protected final java.lang.String name
public Compound(java.lang.String name)
name
- the name of this Compoundprotected Compound(java.lang.String name, int arity)
name
- the name of this Compoundarity
- the arity of this Compoundpublic Compound(java.lang.String name, Term[] args)
name
- the name of this Compoundargs
- the (one or more) arguments of this Compoundpublic final Term arg(int i)
public final Term[] args()
public final int arity()
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the Object to compare (not necessarily another Compound)protected final void getSubst(java.util.Map<java.lang.String,Term> varnames_to_Terms, java.util.Map<term_t,Variable> vars_to_Vars)
public final boolean hasFunctor(java.lang.String name, int arity)
hasFunctor
in class Term
public boolean isJFalse()
public boolean isJNull()
public boolean isJObject()
public boolean isJRef()
public boolean isJTrue()
public boolean isJVoid()
public final boolean isListPair()
isListPair
in class Term
public java.lang.Object jrefToObject()
jrefToObject
in class Term
public final java.lang.String name()
protected void put(java.util.Map<java.lang.String,term_t> varnames_to_vars, term_t term)
public void setArg(int i, Term arg)
i
- the index (1+) of the arg to be setarg
- the Term which is to become the i-th (from 1) arg of this Compoundpublic java.lang.String toString()
toString
in class java.lang.Object
public int type()