mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-07 15:26:39 +02:00
add swap
This commit is contained in:
13
src/util/swap.scad
Normal file
13
src/util/swap.scad
Normal 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]]
|
||||||
|
);
|
Reference in New Issue
Block a user