mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-13 18:24:28 +02:00
rename
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use <util/_impl/_vt_default_comparator.scad>;
|
||||
|
||||
function _default_sort(lt) =
|
||||
function _vt_sort(lt) =
|
||||
let(leng = len(lt))
|
||||
leng <= 1 ? lt :
|
||||
let(
|
||||
@@ -8,9 +8,9 @@ function _default_sort(lt) =
|
||||
before = [for(j = 1; j < leng; j = j + 1) if(lessThan(lt[j], pivot)) lt[j]],
|
||||
after = [for(j = 1; j < leng; j = j + 1) if(greaterThan(lt[j], pivot) || lt[j] == pivot) lt[j]]
|
||||
)
|
||||
concat(_default_sort(before), [pivot], _default_sort(after));
|
||||
concat(_vt_sort(before), [pivot], _vt_sort(after));
|
||||
|
||||
function _sort(lt, i) =
|
||||
function _sort_by_idx(lt, i) =
|
||||
let(leng = len(lt))
|
||||
leng <= 1 ? lt :
|
||||
let(
|
||||
@@ -18,9 +18,9 @@ function _sort(lt, i) =
|
||||
before = [for(j = 1; j < leng; j = j + 1) if(lt[j][i] < pivot[i]) lt[j]],
|
||||
after = [for(j = 1; j < leng; j = j + 1) if(lt[j][i] >= pivot[i]) lt[j]]
|
||||
)
|
||||
concat(_sort(before, i), [pivot], _sort(after, i));
|
||||
concat(_sort_by_idx(before, i), [pivot], _sort_by_idx(after, i));
|
||||
|
||||
function _sort_impl(lt, by, idx) =
|
||||
function _sort_by(lt, by, idx) =
|
||||
let(
|
||||
dict = [["x", 0], ["y", 1], ["z", 2], ["i", idx]],
|
||||
i = dict[search(by == "idx" ? "i" : by, dict)[0]][1]
|
||||
|
@@ -11,5 +11,5 @@
|
||||
use <util/_impl/_sort_impl.scad>;
|
||||
|
||||
function sort(lt, by = "idx", idx = 0) =
|
||||
by == "vt" ? _default_sort(lt) : // for example, sort by zyx for a list of points
|
||||
_sort_impl(lt, by, idx);
|
||||
by == "vt" ? _vt_sort(lt) : // for example, sort by zyx for a list of points
|
||||
_sort_by(lt, by, idx);
|
Reference in New Issue
Block a user