1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-06 14:56:47 +02:00
This commit is contained in:
Justin Lin
2021-02-27 18:38:41 +08:00
parent 1fcdd829be
commit df8cbba07c

13
src/util/swap.scad Normal file
View File

@@ -0,0 +1,13 @@
function swap(lt, i, j) =
let(
leng = len(lt),
a = min([i, j]),
b = max([i, j])
)
concat(
a == 0 ? [] : [for(idx = [0:a - 1]) lt[idx]],
[lt[b]],
b - a == 1? [] : [for(idx = [a + 1:b - 1]) lt[idx]],
[lt[a]],
b == leng - 1 ? [] : [for(idx = [b + 1:leng - 1]) lt[idx]]
);