mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-04 03:09:45 +00:00
Bugfix for set_union() when b contains duplicate items.
This commit is contained in:
parent
258e162f98
commit
abf1a78290
2 changed files with 16 additions and 7 deletions
21
arrays.scad
21
arrays.scad
|
@ -991,14 +991,23 @@ function permute(l,n=2,_s=0) =
|
||||||
// // set_v now equals [[5,0,1,2,6], [2,3,5,7,11,1,8]]
|
// // set_v now equals [[5,0,1,2,6], [2,3,5,7,11,1,8]]
|
||||||
function set_union(a, b, get_indices=false) =
|
function set_union(a, b, get_indices=false) =
|
||||||
let(
|
let(
|
||||||
found = search(b, a, num_returns_per_match=1),
|
found1 = search(b, a),
|
||||||
nset = concat(a, [
|
found2 = search(b, b),
|
||||||
for (i=idx(found)) if(found[i]==[]) b[i]
|
c = [
|
||||||
])
|
for (i=idx(b))
|
||||||
|
if (found1[i] == [] && found2[i] == i)
|
||||||
|
b[i]
|
||||||
|
],
|
||||||
|
nset = concat(a, c)
|
||||||
) !get_indices? nset :
|
) !get_indices? nset :
|
||||||
let(
|
let(
|
||||||
nidx = cumsum([len(a), for (i=found) (i==[])? 1 : 0]),
|
la = len(a),
|
||||||
idxs = [for (i=idx(found)) (found[i]==[])? nidx[i] : found[i]]
|
found3 = search(b, c),
|
||||||
|
idxs = [
|
||||||
|
for (i=idx(b))
|
||||||
|
(found1[i] != [])? found1[i] :
|
||||||
|
la + found3[i]
|
||||||
|
]
|
||||||
) [idxs, nset];
|
) [idxs, nset];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,249];
|
BOSL_VERSION = [2,0,250];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue