1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-14 10:44:48 +02:00

refactor: don't use each

This commit is contained in:
Justin Lin
2022-04-17 20:04:38 +08:00
parent 92190fbb21
commit 7bcf5d8f27

View File

@@ -5,9 +5,9 @@
* @license https://opensource.org/licenses/lgpl-3.0.html * @license https://opensource.org/licenses/lgpl-3.0.html
* *
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-swap.html * @see https://openhome.cc/eGossip/OpenSCAD/lib3x-swap.html
* *
**/ **/
function swap(lt, i, j) = function swap(lt, i, j) =
i == j ? lt : i == j ? lt :
let( let(
@@ -17,9 +17,8 @@ function swap(lt, i, j) =
b = ab[1] b = ab[1]
) )
[ [
each [for(idx = 0; idx < a; idx = idx + 1) lt[idx]], for(i = [0:leng - 1])
lt[b], if(i == a) lt[b]
each [for(idx = a + 1; idx < b; idx = idx + 1) lt[idx]], else if(i == b) lt[a]
lt[a], else lt[i]
each [for(idx = b + 1; idx < leng; idx = idx + 1) lt[idx]]
]; ];