1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-10 16:54:23 +02:00
This commit is contained in:
Justin Lin
2022-03-11 21:08:40 +08:00
parent 78f6acdabf
commit d60b35dd0d
6 changed files with 13 additions and 18 deletions

View File

@@ -1,3 +0,0 @@
function _every(lt, test, leng, i = 0) =
i == leng ? true :
!test(lt[i]) ? false : _every(lt, test, leng, i + 1);

View File

@@ -1,3 +0,0 @@
function _find_index(lt, test, leng, i = 0) =
i == leng ? -1 :
test(lt[i]) ? i : _find_index(lt, test, leng, i + 1);

View File

@@ -1,3 +0,0 @@
function _some(lt, test, leng, i = 0) =
i == leng ? false :
test(lt[i]) ? true : _some(lt, test, leng, i + 1);

View File

@@ -8,6 +8,6 @@
*
**/
use <_impl/_every.scad>;
function every(lt, test) = _every(lt, test, len(lt));
function every(lt, test) =
let(leng = len(lt))
len([for(i = 0; i < leng && test(lt[i]); i = i + 1) 0]) == leng;

View File

@@ -8,6 +8,10 @@
*
**/
use <_impl/_find_index_impl.scad>;
function find_index(lt, test) = _find_index(lt, test, len(lt));
function find_index(lt, test) =
let(
leng = len(lt),
indices = [for(i = 0; i < leng && !test(lt[i]); i = i + 1) i],
leng_indices = len(indices)
)
leng_indices == leng ? -1 : leng_indices;

View File

@@ -8,6 +8,6 @@
*
**/
use <_impl/_some.scad>;
function some(lt, test) = _some(lt, test, len(lt));
function some(lt, test) =
let(leng = len(lt))
len([for(i = 0; i < leng && !test(lt[i]); i = i + 1) 0]) < leng;