Sorting algorithms/Bogosort: Difference between revisions

Content added Content deleted
m (added Category:Sorting)
(Replaced “import math” by “import random”. Removed proc “shuffle” as it is now provided by the module “random”.)
Line 2,028: Line 2,028:


=={{header|Nim}}==
=={{header|Nim}}==
<lang nim>import math
<lang nim>import random
randomize()


randomize()
proc shuffle[T](x: var openarray[T]) =
for i in countdown(x.high, 0):
let j = random(i + 1)
swap(x[i], x[j])


proc isSorted[T](s: openarray[T]): bool =
proc isSorted[T](s: openarray[T]): bool =