diff --git a/src/util/dedup.scad b/src/util/dedup.scad index 717d18cd..65fc0533 100644 --- a/src/util/dedup.scad +++ b/src/util/dedup.scad @@ -19,11 +19,7 @@ function dedup(lt, eq = function(e1, e2) e1 == e2, hash = function(e) _str_hash( b_numbers = is_undef(number_of_buckets) ? ceil(sqrt(leng_lt)) : number_of_buckets, buckets = [for(i = [0:b_numbers - 1]) []], deduped = _dedup(lt, leng_lt, buckets, eq, hash, b_numbers), - i_elem_lt = [ - for(bucket = deduped) - for(i_elem = bucket) - i_elem - ], + i_elem_lt = [for(bucket = deduped) each bucket], sorted = sort(i_elem_lt, by = function(e1, e2) e1[0] - e2[0]) ) [for(i_elem = sorted) i_elem[1]]; diff --git a/src/util/map/_impl/_hashmap_impl.scad b/src/util/map/_impl/_hashmap_impl.scad index 0b4373d7..e607b9f5 100644 --- a/src/util/map/_impl/_hashmap_impl.scad +++ b/src/util/map/_impl/_hashmap_impl.scad @@ -2,5 +2,8 @@ use <_hashmap_put_impl.scad>; function _hashmap(kv_lt, leng, buckets, b_numbers, eq, hash, i = 0) = i == leng ? buckets : - let(n_buckets = _hashmap_put(buckets, b_numbers, kv_lt[i][0], kv_lt[i][1], eq, hash)) + let( + kv_lt_i = kv_lt[i], + n_buckets = _hashmap_put(buckets, b_numbers, kv_lt_i[0], kv_lt_i[1], eq, hash) + ) _hashmap(kv_lt, leng, n_buckets, b_numbers, eq, hash, i + 1); \ No newline at end of file diff --git a/src/util/map/hashmap_entries.scad b/src/util/map/hashmap_entries.scad index bbbe241f..17f83882 100644 --- a/src/util/map/hashmap_entries.scad +++ b/src/util/map/hashmap_entries.scad @@ -8,8 +8,4 @@ * **/ -function hashmap_entries(map) = [ - for(bucket = map) - for(kv = bucket) - kv -]; \ No newline at end of file +function hashmap_entries(map) = [for(bucket = map) each bucket]; \ No newline at end of file diff --git a/src/util/map/hashmap_len.scad b/src/util/map/hashmap_len.scad index eb9cd025..7263f3d9 100644 --- a/src/util/map/hashmap_len.scad +++ b/src/util/map/hashmap_len.scad @@ -10,7 +10,4 @@ use <../sum.scad>; -function hashmap_len(map) = sum([ - for(bucket = map) - len(bucket) -]); \ No newline at end of file +function hashmap_len(map) = sum([for(bucket = map) len(bucket)]); \ No newline at end of file diff --git a/src/util/set/hashset_elems.scad b/src/util/set/hashset_elems.scad index ae1b1e94..a4eefce1 100644 --- a/src/util/set/hashset_elems.scad +++ b/src/util/set/hashset_elems.scad @@ -8,8 +8,4 @@ * **/ -function hashset_elems(set) = [ - for(bucket = set) - for(elem = bucket) - elem -]; \ No newline at end of file +function hashset_elems(set) = [for(bucket = set) each bucket]; \ No newline at end of file diff --git a/src/util/set/hashset_len.scad b/src/util/set/hashset_len.scad index 7f4b31a5..8e024c78 100644 --- a/src/util/set/hashset_len.scad +++ b/src/util/set/hashset_len.scad @@ -10,7 +10,4 @@ use <../sum.scad>; -function hashset_len(set) = sum([ - for(bucket = set) - len(bucket) -]); \ No newline at end of file +function hashset_len(set) = sum([for(bucket = set) len(bucket)]); \ No newline at end of file