From 7bcf5d8f27932c24cabb32b4c7b89f2c2298fa8e Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 17 Apr 2022 20:04:38 +0800 Subject: [PATCH] refactor: don't use each --- src/util/swap.scad | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/util/swap.scad b/src/util/swap.scad index 0ffd2833..1e3bca8c 100644 --- a/src/util/swap.scad +++ b/src/util/swap.scad @@ -5,9 +5,9 @@ * @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( @@ -17,9 +17,8 @@ function swap(lt, i, j) = b = ab[1] ) [ - each [for(idx = 0; idx < a; idx = idx + 1) lt[idx]], - lt[b], - each [for(idx = a + 1; idx < b; idx = idx + 1) lt[idx]], - lt[a], - each [for(idx = b + 1; idx < leng; idx = idx + 1) lt[idx]] + for(i = [0:leng - 1]) + if(i == a) lt[b] + else if(i == b) lt[a] + else lt[i] ]; \ No newline at end of file