1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00
dotSCAD/docs/lib3x-has.md

25 lines
729 B
Markdown
Raw Normal View History

2020-03-19 08:58:25 +08:00
# has
If `lt` contains `elem`, this function returns `true`. If you want to test elements repeatly, sorting `lt` first and setting `sorted` to `true` will be faster.
**Since:** 2.3
## Parameters
- `lt` : A list of vectors.
- `elem` : A vector.
2020-03-19 17:02:07 +08:00
- `sorted` : If `false` (default), use native `search`. If `true`, `lt` must be sorted by zyx (from the last index to the first one) and `has` will use binary search internally.
2020-03-19 08:58:25 +08:00
## Examples
2022-06-06 13:11:46 +08:00
use <voxel/vx_circle.scad>
use <util/sort.scad>
use <util/has.scad>
2020-03-19 08:58:25 +08:00
2021-02-07 17:25:45 +08:00
pts = vx_circle(10);
2020-03-19 08:58:25 +08:00
assert(has(pts, [2, -10]));
assert(!has(pts, [0, 0]));
2020-03-19 17:02:07 +08:00
sorted_pts = sort(pts, by = "vt");
2020-03-19 08:58:25 +08:00
assert(has(sorted_pts, [2, -10]));
assert(!has(sorted_pts, [0, 0]));