From f0c07f1110120b61ae3882ec9a5a9b7bdba57f31 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 10 Feb 2021 08:42:30 +0800 Subject: [PATCH] add some --- README.md | 1 + docs/lib3x-some.md | 17 +++++++++++++++++ src/util/some.scad | 10 ++++++++++ 3 files changed, 28 insertions(+) create mode 100644 docs/lib3x-some.md diff --git a/README.md b/README.md index aeb5d945..4ba83851 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp - [util/rand](https://openhome.cc/eGossip/OpenSCAD/lib2x-rand.html) - [util/reverse](https://openhome.cc/eGossip/OpenSCAD/lib2x-reverse.html) - [util/slice](https://openhome.cc/eGossip/OpenSCAD/lib2x-slice.html) +- [util/some](https://openhome.cc/eGossip/OpenSCAD/lib3x-some.html) - [util/sort](https://openhome.cc/eGossip/OpenSCAD/lib3x-sort.html) - [util/sub_str](https://openhome.cc/eGossip/OpenSCAD/lib2x-sub_str.html) - [util/split_str](https://openhome.cc/eGossip/OpenSCAD/lib2x-split_str.html) diff --git a/docs/lib3x-some.md b/docs/lib3x-some.md new file mode 100644 index 00000000..f6d0b201 --- /dev/null +++ b/docs/lib3x-some.md @@ -0,0 +1,17 @@ +# some + +The `some` function tests whether at least one element in the list passes the test implemented by the provided function. + +**Since:** 3.0 + +## Parameters + +- `lt` : the list. +- `test` : a test function that accepts an element and returns `true` or `false`. + +## Examples + + use ; + + isOdd = function(elem) elem % 2 == 1; + assert(some([1, 30, 39, 29, 10, 13], isOdd)); \ No newline at end of file diff --git a/src/util/some.scad b/src/util/some.scad index ecaf79e3..57eeeb02 100644 --- a/src/util/some.scad +++ b/src/util/some.scad @@ -1,3 +1,13 @@ +/** +* some.scad +* +* @copyright Justin Lin, 2021 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-some.html +* +**/ + use <_impl/_some.scad>; function some(lt, test) = _some(lt, test, len(lt)); \ No newline at end of file