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

23 lines
700 B
Markdown
Raw Normal View History

2020-05-24 16:24:26 +08:00
# zip
Make a list that aggregates elements from each of the lists. Returns a list of lists, where the i-th list contains the i-th element from each of the argument lists. The `zip` function stops when the first input list is exhausted.
**Since:** 2.4
## Parameters
2021-02-11 11:50:32 +08:00
- `lts` : A list of lists.
2021-02-11 11:54:51 +08:00
- `slider` : Rather than listing the elements, the elements are combined using the function. **Since:** 3.0
2020-05-24 16:24:26 +08:00
## Examples
use <util/zip.scad>;
xs = [10, 20, 30];
ys = [5, 15, 25];
zs = [2.5, 7.5, 12.4];
2021-02-11 11:50:32 +08:00
assert(zip([xs, ys, zs]) == [[10, 5, 2.5], [20, 15, 7.5], [30, 25, 12.4]]);
sum_up = function(elems) sum(elems);
assert(zip([xs, ys, zs], sum_up) == [17.5, 42.5, 67.4]);