mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Handle zero length inputs for list_set and list_remove
This commit is contained in:
parent
ca98f497d1
commit
d86b94193b
1 changed files with 2 additions and 1 deletions
|
@ -190,7 +190,7 @@ function list_set(list=[],indices,values,dflt=0,minlen=0) =
|
|||
assert(len(indices)==len(values),"Index list and value list must have the same length")
|
||||
let(
|
||||
sortind = list_increasing(indices) ? list_range(len(indices)) : sortidx(indices),
|
||||
lastind = indices[select(sortind,-1)]
|
||||
lastind = len(indices)==0 ? -1 : indices[select(sortind,-1)]
|
||||
)
|
||||
concat(
|
||||
[for(j=[0:1:indices[sortind[0]]-1]) j>=len(list) ? dflt : list[j]],
|
||||
|
@ -217,6 +217,7 @@ function list_set(list=[],indices,values,dflt=0,minlen=0) =
|
|||
// elements = The list of indexes of items to remove.
|
||||
function list_remove(list, elements) =
|
||||
!is_list(elements) ? list_remove(list,[elements]) :
|
||||
len(elements)==0 ? list :
|
||||
let( sortind = list_increasing(elements) ? list_range(len(elements)) : sortidx(elements),
|
||||
lastind = elements[select(sortind,-1)]
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue