Package jason.stdlib
Class delete
java.lang.Object
jason.asSemantics.DefaultInternalAction
jason.stdlib.delete
- All Implemented Interfaces:
InternalAction
,Serializable
@Manual(literal=".delete(arg0,arg1,arg2[,arg3])",
hint="delete elements of strings or lists",
argsHint={"if term, this is the element to be removed in the list; if string, this is the substring to be removed; if number, where to start to delete","if arg0 is list/string, the list/string where to delete; if arg0 is number, where to stop to delete","if arg0 is list/string, the list/string with the result of the deletion, if arg0 is number, the list/string where to delete.","if arg0 is number, the list/string with the result of the deletion [present when arg0 is a number]"},
argsType={"term, string, or number","number, list or string","number, list or string","list or string"},
examples={".delete(a,[a,b,c,a],L): L unifies with [b,c]",".delete(a,[a,b,c,a],[c]): false",".delete(0,[a,b,c,a],L): L unifies with [b,c,a]",".delete(1,3,[a,b,c,a],L): L unifies with [a,a]",".delete(\"a\",\"banana\",S): S unifies with \"bnn\"",".delete(0,\"banana\",S): S unifies with \"anana\""},
seeAlso={"jason.stdlib.concat","jason.stdlib.length","jason.stdlib.member","jason.stdlib.sort","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 delete
extends DefaultInternalAction
Internal action: .delete
.
Description: delete elements of strings or lists.
Parameters:
- + arg[0] (term, string, or number): if term, this arg is the element to be removed in the list (all occurrences of the element will be removed);
if string, this arg is the substring to be removed (the second arg should be a string);
if number, this arg is the position in the list/string of the element/character to be removed.
- + arg[1] (list or string): the list/string where to delete.
- +/- arg[2] (list or string): the list/string with the result of the deletion.
Examples:
-
.delete(a,[a,b,c,a],L)
:L
unifies with [b,c]. -
.delete(a,[a,b,c,a],[c])
: false. -
.delete(0,[a,b,c,a],L)
:L
unifies with [b,c,a]. -
.delete(1,3,[a,b,c,a],L)
:L
unifies with [a,a]. -
.delete("a","banana",S)
:S
unifies with "bnn". -
.delete(0,"banana",S)
:S
unifies with "anana".
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic InternalAction
create()
execute
(TransitionSystem ts, Unifier un, Term[] args) Executes the internal action.int
int
Methods inherited from class jason.asSemantics.DefaultInternalAction
canBeUsedInContext, checkArguments, destroy, prepareArguments, suspendIntention
-
Constructor Details
-
delete
public delete()
-
-
Method Details
-
create
-
getMinArgs
public int getMinArgs()- Overrides:
getMinArgs
in classDefaultInternalAction
-
getMaxArgs
public int getMaxArgs()- Overrides:
getMaxArgs
in classDefaultInternalAction
-
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
-