❔ Can I use slice operator with loop index (remainder operator%)?
I want to slice an array from start to end index but if end index exceeds the array length, loop it and start from index 0 (remainder operator%)
7 Replies
but then the end index could be smaller than the start index
So?
I have to use array index with remainder operator and add these elements to a list?
Array with 10 elements.
Start from index 8 and length 5
Index 8,9,0,1,2
For example
oh thats what you meant
what if the length is 12
do items get repeated, or just returns the last 2 items?
i guess the latter makes more sense
I do no know what you mean
It was an example.
If the length is 12 and start from index 8 with 5 length, it returns
8,9,10,11,0
not the length of the array
same array of 10 elements
start at index 8 with length 12 instead of 5
I said it should be looped
so
8,9,0,1,2,...9
I do not know what is the difference?
but this sequence length is max 10 (array element size) in my scenario
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.