In Euphoria, the splice()
method is a built-in subroutine used to perform certain operations on a sequence.
This method will bridge a sequence at a particular indicated position, and insert specified data at the position of the bridge.
The illustration above shows how the splice method introduces a new set of data at the position 2
of the sequence.
splice(whatToSplice, spliceWith,splicePosition)
whatToSplice
: This represents the sequence which will be spliced.spliceWith
: This represents the data, which will be added to the sequence.splicePosition
: This represents the index of the sequence from which the splicing will start.It returns a sequence with a length equal to that of whatToSplice
, and the length of spliceWith
joined together.
--define an objectobject result--define a sequencesequence splicingsplicing = "My is john"--invoking the splice function.result = splice( splicing," name",3)printf(1,result)
result
, to save the result of performing a splice
on the variable splicing
.name
string to splicing
on the third spot in the sequence.splice
operation.