1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-16 11:44:50 +02:00
This commit is contained in:
Justin Lin
2022-03-11 15:19:44 +08:00
parent 88a970b2ba
commit 21c00b52d3

View File

@@ -1,4 +1,7 @@
use <../swap.scad>;
function _shuffle(lt, indices, leng, i = 0) =
i == leng ? lt : _shuffle(swap(lt, i, indices[i]), indices, leng, i + 1);
function _shuffle(lt, indices, leng) =
let(end = len(lt) - 1)
end == 0 ? lt :
let(cum = [for(i = 0, s = swap(lt, i, indices[i]); i < end; i = i + 1, s = swap(s, i, indices[i])) s])
swap(cum[len(cum) - 1], end, indices[end]);