Sorting algorithms/Selection sort: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 552: | Line 552: | ||
let rec ssort = function |
let rec ssort = function |
||
[] -> [] |
[] -> [] |
||
| |
| x::xs -> |
||
let |
let min, rest = |
||
List.fold_left (fun (min,acc) x -> |
|||
if h<min then (h, min::acc) |
|||
else (min, h::acc)) |
|||
(x, []) xs |
|||
if h<min then aux t h (min::acc) |
|||
else aux t min (h::acc) |
|||
in aux (List.tail l) (List.head l) [] |
|||
in |
|||
let (min,rest) = minrest l |
|||
in min::ssort rest |
in min::ssort rest |
||
</lang> |
</lang> |