Implement llList2ListSlice

This commit is contained in:
Sei Lisa 2024-04-18 18:08:57 +02:00
parent b7f16900ed
commit 002ef96a9d
3 changed files with 96 additions and 1 deletions

View file

@ -1448,7 +1448,14 @@ def llList2ListSlice(src, start, end, stride, slice_idx):
end = fi(end)
stride = fi(stride)
slice_idx = fi(slice_idx)
raise ELSLCantCompute # TODO: Implement llList2ListSlice
if stride <= 0 or slice_idx < -stride or slice_idx > stride - 1:
return []
# Resolve exclusion range exactly like llList2List, generating a new list.
# NOTE: This bears improvement, by not making an intermediate new list.
src = InternalGetDeleteSubSequence(src, start, end, isGet=True)
if slice_idx < 0:
slice_idx += stride
return src[slice_idx::stride]
def llList2ListStrided(lst, start, end, stride):
lst = fl(lst)