Documented shuffle from random module (#5204)

This commit is contained in:
Benjamin Summerton
2017-01-11 00:05:41 -05:00
committed by Andreas Rumpf
parent c98a8f3701
commit 17c62bb545

View File

@@ -107,6 +107,7 @@ proc randomize*(seed: int) {.benign.} =
state.a1 = ui(seed and 0xffff)
proc shuffle*[T](x: var seq[T]) =
## Will randomly swap the positions of elements in a sequence.
for i in countdown(x.high, 0):
let j = random(i + 1)
swap(x[i], x[j])