mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Syntax fix for group_data() asserts.
This commit is contained in:
parent
8ef32210c4
commit
d57e27f268
1 changed files with 12 additions and 6 deletions
18
arrays.scad
18
arrays.scad
|
@ -1816,16 +1816,22 @@ function array_group(v, cnt=2, dflt=0) =
|
||||||
// Example:
|
// Example:
|
||||||
// groups = group_data([1,3,1], ["A","B","C"]); // Returns [[],["A","C"],[],["B"]]
|
// groups = group_data([1,3,1], ["A","B","C"]); // Returns [[],["A","C"],[],["B"]]
|
||||||
function group_data(groups, values) =
|
function group_data(groups, values) =
|
||||||
assert(all_integer(groups) && all_nonnegative(groups));
|
assert(all_integer(groups) && all_nonnegative(groups))
|
||||||
assert(is_list(values));
|
assert(is_list(values))
|
||||||
assert(len(groups)==len(values),
|
assert(len(groups)==len(values),
|
||||||
"The groups and values arguments should be lists of matching length.")
|
"The groups and values arguments should be lists of matching length.")
|
||||||
let( sorted = _group_sort_by_index(zip(groups,values),0) )
|
let( sorted = _group_sort_by_index(zip(groups,values),0) )
|
||||||
// retrieve values and insert []
|
// retrieve values and insert []
|
||||||
[for(i=idx(sorted))
|
[
|
||||||
let( a = i==0? 0 : sorted[i-1][0][0]+1,
|
for (i = idx(sorted))
|
||||||
g0 = sorted[i] )
|
let(
|
||||||
each [ for(j=[a:1:g0[0][0]-1]) [], [for(g1=g0) g1[1]] ]
|
a = i==0? 0 : sorted[i-1][0][0]+1,
|
||||||
|
g0 = sorted[i]
|
||||||
|
)
|
||||||
|
each [
|
||||||
|
for (j = [a:1:g0[0][0]-1]) [],
|
||||||
|
[for (g1 = g0) g1[1]]
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue