mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
add hashset_len
This commit is contained in:
parent
4ba7a2ee73
commit
5e716fb5f6
6
src/collection/hashset_len.scad
Normal file
6
src/collection/hashset_len.scad
Normal file
@ -0,0 +1,6 @@
|
||||
use <../util/sum.scad>;
|
||||
|
||||
function hashset_len(set) = sum([
|
||||
for(bucket = set)
|
||||
len(bucket)
|
||||
]);
|
@ -4,12 +4,14 @@ use <collection/hashset_list.scad>;
|
||||
use <collection/hashset_add.scad>;
|
||||
use <collection/hashset_del.scad>;
|
||||
use <collection/hashset_has.scad>;
|
||||
use <collection/hashset_len.scad>;
|
||||
|
||||
module test_hashset() {
|
||||
echo("==== test_hashset ====");
|
||||
|
||||
s = hashset([1, 2, 3, 4, 5, 2, 3, 5]);
|
||||
assert(hashset_list(s) == [1, 2, 3, 4, 5]);
|
||||
assert(hashset_len(s) == 5);
|
||||
|
||||
s2 = hashset_add(s, 9);
|
||||
assert(hashset_list(s2) == [1, 2, 3, 4, 5, 9]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user