mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2024-11-21 06:15:56 -07:00
Implement llList2ListSlice
This commit is contained in:
parent
b7f16900ed
commit
002ef96a9d
3 changed files with 96 additions and 1 deletions
|
@ -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)
|
||||
|
|
21
unit_tests/expr.suite/list-funcs-4.lsl
Normal file
21
unit_tests/expr.suite/list-funcs-4.lsl
Normal file
|
@ -0,0 +1,21 @@
|
|||
"T01" + llList2ListSlice([], 0, -1, 1, 0)
|
||||
+ "T02" + llList2ListSlice([], 0, 0, 1, 0)
|
||||
+ "T03" + llList2ListSlice([0,1,2,3,4,5,6], 0, 1, 1, 0)
|
||||
+ "T04" + llList2ListSlice([0,1,2,3,4,5,6], 0, -1, 3, 0)
|
||||
+ "T05" + llList2ListSlice([0,1,2,3,4,5,6], 0, -1, 3, 1)
|
||||
+ "T06" + llList2ListSlice([0,1,2,3,4,5,6], 1, -1, 3, 1)
|
||||
+ "T07" + llList2ListSlice([0,1,2,3,4,5,6], 2, -1, 3, -1)
|
||||
+ "T08" + llList2ListSlice([0,1,2,3,4,5,6], 4, 2, 1, 0)
|
||||
+ "T09" + llList2ListSlice([0,1,2,3,4,5,6], 0, 5, 3, 0)
|
||||
+ "T10" + llList2ListSlice([0,1,2,3,4,5,6], 0, 5, 3, 1)
|
||||
+ "T11" + llList2ListSlice([0,1,2,3,4,5,6], 0, 5, 3, 2)
|
||||
+ "T12" + llList2ListSlice([0,1,2,3,4,5,6], 0, 5, 3, 3)
|
||||
+ "T13" + llList2ListSlice([0,1,2,3,4,5,6], 0, 5, 3, -1)
|
||||
+ "T14" + llList2ListSlice([0,1,2,3,4,5,6], 0, 5, 3, -2)
|
||||
+ "T15" + llList2ListSlice([0,1,2,3,4,5,6], 0, 5, 3, -3)
|
||||
+ "T16" + llList2ListSlice([0,1,2,3,4,5,6], 0, 5, 3, -4)
|
||||
+ "T17" + llList2ListSlice([0,1,2,3,4,5,6], 0, 5, 1, 0)
|
||||
+ "T18" + llList2ListSlice([0,1,2,3,4,5,6], 0, -1, -1, 0)
|
||||
+ "T19" + llList2ListSlice([0,1,2,3,4,5,6], 0, 6, 2, 0)
|
||||
+ "T20" + llList2ListSlice([0,1,2,3,4,5,6], 0, 7, 2, 0)
|
||||
+ "T21" + llList2ListSlice([0,1,2,3,4,5,6], 0, -3, 2, 0)
|
67
unit_tests/expr.suite/list-funcs-4.out
Normal file
67
unit_tests/expr.suite/list-funcs-4.out
Normal file
|
@ -0,0 +1,67 @@
|
|||
[ "T01"
|
||||
, "T02"
|
||||
, "T03"
|
||||
, 0
|
||||
, 1
|
||||
, "T04"
|
||||
, 0
|
||||
, 3
|
||||
, 6
|
||||
, "T05"
|
||||
, 1
|
||||
, 4
|
||||
, "T06"
|
||||
, 2
|
||||
, 5
|
||||
, "T07"
|
||||
, 4
|
||||
, "T08"
|
||||
, 0
|
||||
, 1
|
||||
, 2
|
||||
, 4
|
||||
, 5
|
||||
, 6
|
||||
, "T09"
|
||||
, 0
|
||||
, 3
|
||||
, "T10"
|
||||
, 1
|
||||
, 4
|
||||
, "T11"
|
||||
, 2
|
||||
, 5
|
||||
, "T12"
|
||||
, "T13"
|
||||
, 2
|
||||
, 5
|
||||
, "T14"
|
||||
, 1
|
||||
, 4
|
||||
, "T15"
|
||||
, 0
|
||||
, 3
|
||||
, "T16"
|
||||
, "T17"
|
||||
, 0
|
||||
, 1
|
||||
, 2
|
||||
, 3
|
||||
, 4
|
||||
, 5
|
||||
, "T18"
|
||||
, "T19"
|
||||
, 0
|
||||
, 2
|
||||
, 4
|
||||
, 6
|
||||
, "T20"
|
||||
, 0
|
||||
, 2
|
||||
, 4
|
||||
, 6
|
||||
, "T21"
|
||||
, 0
|
||||
, 2
|
||||
, 4
|
||||
]
|
Loading…
Reference in a new issue