Closed makitard closed 1 year ago
We are currently rewriting spwn (check out the RWRT branch) and the std isn't ready yet for rewrite, but this algorithm will still be useful. Keep this code up until we finally get on rewriting the std library.
Btw, there are two problems with your algorithm.
1) the algorithm can select already shuffled elements, which means that some permutations can occur multiple times (this can be fixed with setting the random index to $.random(i..arr.length)
)
2) the temp = a; a = b; b = temp;
code is inefficient, a <=> b
would be faster.
Btw, there are two problems with your algorithm.
1) the algorithm can select already shuffled elements, which means that some permutations can occur multiple times (this can be fixed with setting the random index to
$.random(i..arr.length)
) 2) thetemp = a; a = b; b = temp;
code is inefficient,a <=> b
would be faster.
thanks for the feedback. didn't know a <=> b
was valid spwn syntax
please