
jason.stdlib.structure Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jason Show documentation
Show all versions of jason Show documentation
Jason is a programming language to develop BDI/cognitive agents
The newest version!
package jason.stdlib;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.InternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.Term;
/**
Internal action: .structure
.
Description: checks whether the argument is a structure, e.g.: "p", "p(1)",
"[a,b]". Numbers, strings and free variables are not structures.
Parameter:
- + argument (any term): the term to be checked.
Examples:
-
.structure(b(10))
: true.
-
.structure(b)
: true.
-
.structure(10)
: false.
-
.structure("home page")
: false.
-
.structure(X)
: false if X is free, true if X is bound to a structure.
-
.structure(a(X))
: true.
-
.structure([a,b,c])
: true.
-
.structure([a,b,c(X)])
: true.
@see jason.stdlib.atom
@see jason.stdlib.list
@see jason.stdlib.literal
@see jason.stdlib.number
@see jason.stdlib.string
@see jason.stdlib.ground
*/
@Manual(
literal=".structure(argument)",
hint="checks whether the argument is a structure",
argsHint= {
"the term to be checked"
},
argsType= {
"term"
},
examples= {
".structure(b(10)): true",
".structure(b): true",
".structure(10): false",
".structure(\"home page\"): false",
".structure(X): false if X is free, true if X is bound to a structure",
".structure(a(X)): true",
".structure(~c(f)): true",
".structure([a,b,c]): true",
".structure([a,b,c(X)]): true"
},
seeAlso= {
"jason.stdlib.atom",
"jason.stdlib.list",
"jason.stdlib.literal",
"jason.stdlib.number",
"jason.stdlib.string",
"jason.stdlib.ground"
}
)
@SuppressWarnings("serial")
public class structure extends DefaultInternalAction {
private static InternalAction singleton = null;
public static InternalAction create() {
if (singleton == null)
singleton = new structure();
return singleton;
}
@Override public int getMinArgs() {
return 1;
}
@Override public int getMaxArgs() {
return 1;
}
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
return args[0].isStructure();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy