jason.stdlib.number 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 fully-fledged interpreter for an extended version of AgentSpeak, a BDI agent-oriented logic programming language.
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: .number
.
Description: checks whether the argument is a number.
Parameter:
- + argument (any term): the term to be checked.
Examples:
-
.number(10)
: true.
-
.number(10.34)
: true.
-
.number(b(10))
: false.
-
.number("home page")
: false.
-
.number(X)
: false if X is free, true if X is bound to a number.
@see jason.stdlib.atom
@see jason.stdlib.list
@see jason.stdlib.literal
@see jason.stdlib.string
@see jason.stdlib.structure
@see jason.stdlib.ground
*/
public class number extends DefaultInternalAction {
private static InternalAction singleton = null;
public static InternalAction create() {
if (singleton == null)
singleton = new number();
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].isNumeric();
}
}