lst = [0, 1, 2, 3, 4]
lst.slice(1, 3) '[1, 2, 3], from 1 to 3 - compare to "01234".mid(1, 3)'
lst.slice(3) '[2, 3, 4], from 2 onward - compare to "01234".mid(2)'
lst.slice(-3) '[2, 3, 4], last 3 - compare to "01234".right(3)'
lst.slice(-1, 0, -1) '[4, 3, 2, 1, 0], i.e. reversed, "from the end to the beginning, going backwards"'
lst.slice() '[0, 1, 2, 3, 4], array COPY - loosely akin to tmp=[]: tmp.append(lst): return tmp'
function arraySlice(arr as Object, start=0 as Integer, finish=-1 as Integer, step_=1 as Integer) as Object:
if GetInterface(arr, "ifArray") = invalid then print "ValueError: arr not ifArray much" : STOP
if step_ = 0 then print "ValueError: slice step cannot be zero" : STOP
if start < 0 then start += arr.count() 'adjust, negative counts backwards from the end'
if finish < 0 then finish += arr.count()
res = []
for i = start to finish step step_:
res.push(arr[i])
next
return res
end function
So... 4 years later, how far have you gotten through adding those 10 lines?
I guess since it's so easy to just code it as a Function there's not really a need for it.
That applies to half of the API though. Yet that still exists.