Sanchime.Learn/Algrithms/Sorts/QuickSort.fs

11 lines
308 B
Forth
Raw Normal View History

2022-07-05 20:26:22 +08:00
namespace Sanchime.Algrithm.Sort
[<AutoOpen>]
module Quick =
let rec qsort sorted = function
| [] -> []
| [x] -> [x]
| x::xs ->
let smaller,larger = xs |> List.partition (fun i -> sorted i x)
(qsort sorted smaller) @ [x] @ qsort sorted larger