mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 22:28:16 +01:00
refactor: use list comprehension
This commit is contained in:
parent
3dc5a9fea2
commit
493645bc7e
@ -1,6 +0,0 @@
|
||||
_identity = function(elems) elems;
|
||||
|
||||
function _zipAll_sub(lts, list_to, elem_to, combine, i = 0) =
|
||||
i > elem_to ? [] : [combine([for(j = [0:list_to]) lts[j][i]]), each _zipAll_sub(lts, list_to, elem_to, combine, i + 1)];
|
||||
|
||||
function _zipAll(lts, combine = _identity) = _zipAll_sub(lts, len(lts) - 1, len(lts[0]) - 1, combine);
|
@ -8,6 +8,9 @@
|
||||
*
|
||||
**/
|
||||
|
||||
use <_impl/_zip_impl.scad>;
|
||||
|
||||
function zip(lts, combine) = is_function(combine) ? _zipAll(lts, combine) : _zipAll(lts);
|
||||
function zip(lts, combine = function(elems) elems) =
|
||||
let(end_lts = len(lts) - 1)
|
||||
[
|
||||
for(i = [0:len(lts[0]) - 1])
|
||||
combine([for(j = [0:end_lts]) lts[j][i]])
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user