From ed1027f9de1dd4f0c50ca594005e104c5ff4b88b Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 18 Apr 2022 16:35:40 +0800 Subject: [PATCH] refactor: is_undef(combine) --- src/util/zip.scad | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/util/zip.scad b/src/util/zip.scad index b2d7f427..5eef9ea7 100644 --- a/src/util/zip.scad +++ b/src/util/zip.scad @@ -8,9 +8,14 @@ * **/ -function zip(lts, combine = function(elems) elems) = +function zip(lts, combine) = let(end_lts = len(lts) - 1) - [ - for(i = [0:len(lts[0]) - 1]) - combine([for(j = [0:end_lts]) lts[j][i]]) - ]; \ No newline at end of file + is_undef(combine) ? + [ + for(i = [0:len(lts[0]) - 1]) + [for(j = [0:end_lts]) lts[j][i]] + ] : + [ + for(i = [0:len(lts[0]) - 1]) + combine([for(j = [0:end_lts]) lts[j][i]]) + ]; \ No newline at end of file