From d57e27f2686967e898aa68c9d97ca2f916747b43 Mon Sep 17 00:00:00 2001 From: Garth Minette Date: Wed, 30 Jun 2021 17:20:37 -0700 Subject: [PATCH] Syntax fix for group_data() asserts. --- arrays.scad | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arrays.scad b/arrays.scad index bf236ce..3d96a86 100644 --- a/arrays.scad +++ b/arrays.scad @@ -1816,16 +1816,22 @@ function array_group(v, cnt=2, dflt=0) = // Example: // groups = group_data([1,3,1], ["A","B","C"]); // Returns [[],["A","C"],[],["B"]] function group_data(groups, values) = - assert(all_integer(groups) && all_nonnegative(groups)); - assert(is_list(values)); + assert(all_integer(groups) && all_nonnegative(groups)) + assert(is_list(values)) assert(len(groups)==len(values), "The groups and values arguments should be lists of matching length.") let( sorted = _group_sort_by_index(zip(groups,values),0) ) // retrieve values and insert [] - [for(i=idx(sorted)) - let( 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]] ] + [ + for (i = idx(sorted)) + let( + 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]] + ] ];