Package jason.stdlib
Class range
java.lang.Object
jason.asSemantics.DefaultInternalAction
jason.stdlib.range
- All Implemented Interfaces:
InternalAction
,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:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkArguments
(Term[] args) static InternalAction
create()
execute
(TransitionSystem ts, Unifier un, Term[] args) Executes the internal action.int
int
Methods inherited from class jason.asSemantics.DefaultInternalAction
canBeUsedInContext, destroy, prepareArguments, suspendIntention
-
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
Description 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:
Exception
-