The mid()
method is used to slice a sequence source
from a start_point
to a given length
.
mid(source,start_point,length)
Let’s look at the different parameters used by this function below:
source
: This is the sequence which will be spliced at the indicated point and to the indicated length.
start_point
: This is an atom value which indicates an index in the source
where the splicing will begin.
length
: This the length which we want the sliced value to have, that is, how much we want the source
to be spliced. It is an atom value and should be less that or equal to the length of the source
variable.
The mid()
method returns a sequence with elements less than or equal to the length
parameter.
--include the sequence moduleinclude std/sequence.e--declare some variablessequence source1,source2sequence outcome1, outcome2--assign values to declared variablessource1 = {1,2,3,4,5,6,7}source2 = "This is a good day"--use the mid() methodoutcome1 = mid(source1,2,4)outcome2 = mid(source2,1,8)print(1, {outcome1})printf(1,"\n%s", {outcome2})
sequence.e
module.mid()
to the output1
and output2
variables.