mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-21 14:04:53 +02:00
dedup sorted lt fastly
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
use <util/has.scad>;
|
||||
|
||||
function _dedup_sorted(lt, leng) =
|
||||
leng == 0 ? lt :
|
||||
concat(
|
||||
[lt[0]],
|
||||
[for(i = [1:leng - 1]) if(lt[i] != lt[i - 1]) lt[i]]
|
||||
);
|
||||
|
||||
function _dedup(src, dest, leng, i = 0) =
|
||||
i == leng ? dest :
|
||||
has(dest, src[i]) ? _dedup(src, dest, leng, i + 1) : _dedup(src, concat(dest, [src[i]]), leng, i + 1);
|
||||
has(dest, src[i]) ? _dedup(src, dest, leng, i + 1) :
|
||||
_dedup(src, concat(dest, [src[i]]), leng, i + 1);
|
@@ -1,3 +1,5 @@
|
||||
use <util/_impl/_dedup_impl.scad>;
|
||||
|
||||
function dedup(lt) = _dedup(lt, [], len(lt));
|
||||
function dedup(lt, sorted = false) =
|
||||
sorted ? _dedup_sorted(lt, len(lt)) :
|
||||
_dedup(lt, [], len(lt));
|
Reference in New Issue
Block a user