mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-16 03:34:42 +02:00
add docs
This commit is contained in:
@@ -137,21 +137,21 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp
|
||||
- list
|
||||
- [util/bsearch](https://openhome.cc/eGossip/OpenSCAD/lib3x-bsearch.html)
|
||||
- [util/has](https://openhome.cc/eGossip/OpenSCAD/lib3x-has.html)
|
||||
- `util/find_index`
|
||||
- [util/find_index](https://openhome.cc/eGossip/OpenSCAD/lib3x-find_index.html)
|
||||
- [util/dedup](https://openhome.cc/eGossip/OpenSCAD/lib3x-dedup.html)
|
||||
- [util/flat](https://openhome.cc/eGossip/OpenSCAD/lib3x-flat.html)
|
||||
- [util/reverse](https://openhome.cc/eGossip/OpenSCAD/lib3x-reverse.html)
|
||||
- [util/slice](https://openhome.cc/eGossip/OpenSCAD/lib3x-slice.html)
|
||||
- [util/sort](https://openhome.cc/eGossip/OpenSCAD/lib3x-sort.html)
|
||||
- [util/sum](https://openhome.cc/eGossip/OpenSCAD/lib3x-sum.html)
|
||||
- `util/swap`
|
||||
- [util/swap](https://openhome.cc/eGossip/OpenSCAD/lib3x-swap.html)
|
||||
- [util/zip](https://openhome.cc/eGossip/OpenSCAD/lib3x-zip.html)
|
||||
- [util/every](https://openhome.cc/eGossip/OpenSCAD/lib3x-every.html)
|
||||
- [util/some](https://openhome.cc/eGossip/OpenSCAD/lib3x-some.html)
|
||||
- random
|
||||
- [util/choose](https://openhome.cc/eGossip/OpenSCAD/lib3x-choose.html)
|
||||
- [util/rand](https://openhome.cc/eGossip/OpenSCAD/lib3x-rand.html)
|
||||
- `util/shuffle`
|
||||
- [util/shuffle](https://openhome.cc/eGossip/OpenSCAD/lib3x-shuffle.html)
|
||||
- string
|
||||
- [util/parse_number](https://openhome.cc/eGossip/OpenSCAD/lib3x-parse_number.html)
|
||||
- [util/split_str](https://openhome.cc/eGossip/OpenSCAD/lib3x-split_str.html)
|
||||
|
16
docs/lib3x-find_index.md
Normal file
16
docs/lib3x-find_index.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# find_index
|
||||
|
||||
Returns the index of the first element in the list that satisfies the testing function. If no element passed the test, it returns -1.
|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
|
||||
- `lt` : The list.
|
||||
- `test` : the testing function.
|
||||
|
||||
## Examples
|
||||
|
||||
use <util/find_index.scad>;
|
||||
|
||||
assert(find_index([10, 20, 30, 40], function(e) e > 10) == 1);
|
16
docs/lib3x-shuffle.md
Normal file
16
docs/lib3x-shuffle.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# shuffle
|
||||
|
||||
Randomizes the order of the elements of a list.
|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
|
||||
- `lt` : The list to shuffle.
|
||||
- `seed` : Random seed value.
|
||||
|
||||
## Examples
|
||||
|
||||
use <util/shuffle.scad>;
|
||||
|
||||
echo(shuffle([1, 2, 3, 4]));
|
17
docs/lib3x-swap.md
Normal file
17
docs/lib3x-swap.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# swap
|
||||
|
||||
Swaps two elements in a list.
|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
|
||||
- `lt` : The list.
|
||||
- `i` : The index of an element.
|
||||
- `j` : The index of the other element
|
||||
|
||||
## Examples
|
||||
|
||||
use <util/swap.scad>;
|
||||
|
||||
assert(swap([10, 20, 30, 40], 1, 3) == [10, 40, 30, 20]);
|
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* swap.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2021
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-swap.html
|
||||
*
|
||||
**/
|
||||
|
||||
function swap(lt, i, j) =
|
||||
i == j ? lt :
|
||||
let(
|
||||
|
Reference in New Issue
Block a user