mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-15 03:05:41 +02:00
refactor
This commit is contained in:
@@ -6,4 +6,8 @@ dotSCAD 3.0 Dev
|
|||||||
|
|
||||||
- `util/sort`: `by` accepts a function literal.
|
- `util/sort`: `by` accepts a function literal.
|
||||||
- `util/bsearch`: only supports `sorted` and `target` parameters. I view it as a new function.
|
- `util/bsearch`: only supports `sorted` and `target` parameters. I view it as a new function.
|
||||||
- `util/dedup`: add the `eq` parameter.
|
- `util/dedup`: add the `eq` parameter.
|
||||||
|
|
||||||
|
New modules/functions
|
||||||
|
|
||||||
|
- `some`
|
@@ -1,3 +1,5 @@
|
|||||||
|
use <../some.scad> ;
|
||||||
|
|
||||||
function _dedup_sorted(lt, leng, eq) =
|
function _dedup_sorted(lt, leng, eq) =
|
||||||
leng == 0 ? lt :
|
leng == 0 ? lt :
|
||||||
is_function(eq) ?
|
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]]
|
[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) =
|
function _dedup_vt(src, dest, leng, i = 0) =
|
||||||
i == leng ? dest :
|
i == leng ? dest :
|
||||||
// src[i] in dest ?
|
// src[i] in dest ?
|
||||||
|
5
src/util/some.scad
Normal file
5
src/util/some.scad
Normal 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));
|
Reference in New Issue
Block a user