1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-13 18:24:28 +02:00
This commit is contained in:
Justin Lin
2021-02-09 10:29:23 +08:00
parent 831f1d04e9
commit d4042c93e3
3 changed files with 12 additions and 7 deletions

View File

@@ -7,3 +7,7 @@ dotSCAD 3.0 Dev
- `util/sort`: `by` accepts a function literal.
- `util/bsearch`: only supports `sorted` and `target` parameters. I view it as a new function.
- `util/dedup`: add the `eq` parameter.
New modules/functions
- `some`

View File

@@ -1,3 +1,5 @@
use <../some.scad> ;
function _dedup_sorted(lt, leng, eq) =
leng == 0 ? lt :
is_function(eq) ?
@@ -10,12 +12,6 @@ function _dedup_sorted(lt, leng, eq) =
[for(i = [1:leng - 1]) if(lt[i] != lt[i - 1]) lt[i]]
);
function _some(dest, assert_func, leng, i = 0) =
i == leng ? false :
assert_func(dest[i]) ? true : _some(dest, assert_func, leng, i + 1);
function some(dest, assert_func) = _some(dest, assert_func, len(dest));
function _dedup_vt(src, dest, leng, i = 0) =
i == leng ? dest :
// src[i] in dest ?

5
src/util/some.scad Normal file
View File

@@ -0,0 +1,5 @@
function _some(dest, assert_func, leng, i = 0) =
i == leng ? false :
assert_func(dest[i]) ? true : _some(dest, assert_func, leng, i + 1);
function some(dest, assert_func) = _some(dest, assert_func, len(dest));