Package jason.stdlib
Class range
java.lang.Object
jason.asSemantics.DefaultInternalAction
jason.stdlib.range
- All Implemented Interfaces:
InternalAction
,java.io.Serializable
@Manual(literal=".range(variable,start,end,step)", hint="backtrack all values for given variable starting, finishing and increments according to given parameters", argsHint={"the variable that unifies with all values","initial value","last value","step (default value is 1) [optional]"}, argsType={"variable","number","number","number"}, examples={".range(3,1,5): true",".range(6,1,5): false",".range(X,1,5): unifies X with 1, 2, 3, 4, and 5",".range(X,1,11,2): unifies X with 2, 4, 6, 8, and 10",".range(X,5,1,-1): unifies X with 5, 4, 3, 2, and 1"}, seeAlso="jason.stdlib.foreach") public class range extends DefaultInternalAction
Internal action: .range(Var,Start,End, Step)
.
Description: backtrack all values for Var starting at Start and finishing at End by increments of Step (default step value is 1).
Parameters:
- +/- var (Variable): the variable that unifies with all values.
- + start (number): initial value.
- + end (number): last value.
- + end (number -- optional): step.
Examples:
-
.range(3,1,5)
: true. -
.range(6,1,5)
: false. -
.range(X,1,5)
: unifies X with 1, 2, 3, 4, and 5. -
.range(X,1,11,2)
: unifies X with 2, 4, 6, 8, and 10. -
.range(X,5,1,-1)
: unifies X with 5, 4, 3, 2, and 1.
- See Also:
for
, Serialized Form
-
Field Summary
Fields Modifier and Type Field Description private static InternalAction
singleton
-
Constructor Summary
Constructors Constructor Description range()
-
Method Summary
Modifier and Type Method Description protected void
checkArguments(Term[] args)
static InternalAction
create()
java.lang.Object
execute(TransitionSystem ts, Unifier un, Term[] args)
Executes the internal action.int
getMaxArgs()
int
getMinArgs()
Methods inherited from class jason.asSemantics.DefaultInternalAction
canBeUsedInContext, destroy, prepareArguments, suspendIntention
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
singleton
-
-
Constructor Details
-
range
public range()
-
-
Method Details
-
create
-
getMinArgs
public int getMinArgs()- Overrides:
getMinArgs
in classDefaultInternalAction
-
getMaxArgs
public int getMaxArgs()- Overrides:
getMaxArgs
in classDefaultInternalAction
-
checkArguments
- Overrides:
checkArguments
in classDefaultInternalAction
- Throws:
JasonException
-
execute
public java.lang.Object execute(TransitionSystem ts, Unifier un, Term[] args) throws java.lang.ExceptionDescription copied from interface:InternalAction
Executes the internal action. It should return a Boolean or an Iterator. A true boolean return means that the IA was successfully executed. An Iterator result means that there is more than one answer for this IA (e.g. see member internal action). - Specified by:
execute
in interfaceInternalAction
- Overrides:
execute
in classDefaultInternalAction
- Throws:
java.lang.Exception
-