mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 06:08:31 +01:00
add count
This commit is contained in:
parent
2a7c38915b
commit
18991671f8
@ -11,4 +11,5 @@ new:
|
||||
- t3d - roll/pitch/forward
|
||||
- polyline_join: doc multi-childs
|
||||
- mz_squarewalls, mz_hexwalls
|
||||
- mz_hamiltonian supports init_cells
|
||||
- mz_hamiltonian supports init_cells
|
||||
- util/count
|
1
src/util/count.scad
Normal file
1
src/util/count.scad
Normal file
@ -0,0 +1 @@
|
||||
function count(lt, test) = len([for(elem = lt) if(test(elem)) undef]);
|
@ -75,6 +75,7 @@ include <util/test_every.scad>;
|
||||
include <util/test_shuffle.scad>;
|
||||
include <util/test_find_index.scad>;
|
||||
include <util/test_spherical_coordinate.scad>;
|
||||
include <util/test_count.scad>;
|
||||
include <util/set/test_hashset.scad>;
|
||||
include <util/map/test_hashmap.scad>;
|
||||
|
||||
|
10
test/util/test_count.scad
Normal file
10
test/util/test_count.scad
Normal file
@ -0,0 +1,10 @@
|
||||
use <util/count.scad>;
|
||||
|
||||
module test_count() {
|
||||
echo("==== test_count ====");
|
||||
|
||||
points = [[7, 2, 2], [1, 1, 2], [3, 4, 2], [3, 4, 2], [1, 2, 3]];
|
||||
assert(count(points, function(p) norm(p) > 5) == 3);
|
||||
}
|
||||
|
||||
test_count();
|
Loading…
x
Reference in New Issue
Block a user