Sorting algorithms/Bogosort: Difference between revisions
Content added Content deleted
Line 388: | Line 388: | ||
RETURN TRUE; |
RETURN TRUE; |
||
END Sorted; |
END Sorted; |
||
PROCEDURE PrintArray(VAR a: ARRAY OF INTEGER); |
|||
VAR i: INTEGER; |
|||
BEGIN |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
END PrintArray; |
|||
PROCEDURE Shuffle*(VAR a: ARRAY OF INTEGER); |
PROCEDURE Shuffle*(VAR a: ARRAY OF INTEGER); |
||
Line 415: | Line 406: | ||
Shuffle(a); |
Shuffle(a); |
||
END; |
END; |
||
⚫ | |||
PrintArray(a); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
Out.Ln; |
Out.Ln; |
||
END Bogo.</pre> |
END Bogo.</pre> |
||
Init initializes the array as 1 |
Init initializes the array as 1 thru 10, then it is shuffled, and then the while loop continually shuffles until Sorted returns true. |
||
=={{header|OCaml}}== |
=={{header|OCaml}}== |