diff --git a/src/util/_impl/_find_index_impl.scad b/src/util/_impl/_find_index_impl.scad new file mode 100644 index 00000000..0e10b037 --- /dev/null +++ b/src/util/_impl/_find_index_impl.scad @@ -0,0 +1,3 @@ +function _find_index(lt, test, leng, i = 0) = + i == leng ? -1 : + test(lt[i]) ? i : _find_index(lt, test, leng, i + 1); \ No newline at end of file diff --git a/src/util/find_index.scad b/src/util/find_index.scad index 5c102f96..e5e5c634 100644 --- a/src/util/find_index.scad +++ b/src/util/find_index.scad @@ -1,5 +1,13 @@ -function find_index(lt, test) = _find_index(lt, test, len(lt)); +/** +* find_index.scad +* +* @copyright Justin Lin, 2021 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-find_index.html +* +**/ -function _find_index(lt, test, leng, i = 0) = - i == leng ? -1 : - test(lt[i]) ? i : _find_index(lt, test, leng, i + 1); \ No newline at end of file +use <_impl/_find_index_impl.scad>; + +function find_index(lt, test) = _find_index(lt, test, len(lt)); \ No newline at end of file