Package jason.stdlib
Class delete
java.lang.Object
jason.asSemantics.DefaultInternalAction
jason.stdlib.delete
- All Implemented Interfaces:
InternalAction
,java.io.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:
concat
,length
,member
,sort
,substring
,nth
,max
,min
,reverse
,difference
,intersection
,union
, Serialized Form
-
Field Summary
Fields Modifier and Type Field Description private static InternalAction
singleton
-
Constructor Summary
Constructors Constructor Description delete()
-
Method Summary
Modifier and Type Method Description static InternalAction
create()
(package private) ListTerm
deleteFromList(int index, int end, ListTerm l)
(package private) ListTerm
deleteFromList(Term element, ListTerm l, Unifier un)
(package private) StringTerm
deleteFromString(int index, int end, StringTerm st)
(package private) StringTerm
deleteFromString(StringTerm st1, StringTerm st2)
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, checkArguments, 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
-
delete
public delete()
-
-
Method Details
-
create
-
getMinArgs
public int getMinArgs()- Overrides:
getMinArgs
in classDefaultInternalAction
-
getMaxArgs
public int getMaxArgs()- Overrides:
getMaxArgs
in classDefaultInternalAction
-
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
-
deleteFromList
-
deleteFromList
-
deleteFromString
-
deleteFromString
-