Package jason.stdlib
Class sublist
java.lang.Object
jason.asSemantics.DefaultInternalAction
jason.stdlib.sublist
- All Implemented Interfaces:
InternalAction
,Serializable
@Manual(literal=".sublist(sublist,list)",
hint="checks if a list is a subset of a given list, backtracking all free variables",
argsHint={"the sublist to be checked","the list where the sublist may be to be a subset"},
argsType={"list","list"},
examples={".sublist([a],[a,b,c]): true",".sublist([b],[a,b,c]): true",".sublist([c],[a,b,c]): true",".sublist([a,b],[a,b,c]): true",".sublist([b,c],[a,b,c]): true",".sublist([d],[a,b,c]): false",".sublist(X,[a,b,c]): unifies X with any sublist of the list, i.e., [a,b,c], [a,b], [a], [b,c], [b], [c], and [] in this order"},
seeAlso={"jason.stdlib.concat","jason.stdlib.delete","jason.stdlib.length","jason.stdlib.member","jason.stdlib.sort","jason.stdlib.shuffle","jason.stdlib.substring","jason.stdlib.nth","jason.stdlib.max","jason.stdlib.min","jason.stdlib.reverse","jason.stdlib.difference","jason.stdlib.intersection","jason.stdlib.union"})
public class sublist
extends DefaultInternalAction
Internal action: .sublist(S,L)
.
Description: checks if some list S is a sublist of list L. If S has free variables, this internal action backtracks all possible values for S. This is based on .prefix and .suffix (try prefixes first then prefixes of each suffix).
Parameters:
- +/- sublist (list): the sublist to be checked.
- + list (list): the list where the sublist is from.
Examples:
-
.sublist([a],[a,b,c])
: true. -
.sublist([b],[a,b,c])
: true. -
.sublist([c],[a,b,c])
: true. -
.sublist([a,b],[a,b,c])
: true. -
.sublist([b,c],[a,b,c])
: true. -
.sublist([d],[a,b,c])
: false. -
.sublist([a,c],[a,b,c])
: false. -
.sublist(X,[a,b,c])
: unifies X with any sublist of the list, i.e., [a,b,c], [a,b], [a], [b,c], [b], [c], and [] in this order; note that this is not the order in which its usual implementation would return in logic programming (see note on .prefix).
- 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
-
sublist
public sublist()
-
-
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
-