用F#实现快速排序

//快速排序

open System

let rec QuickSort(xs:List<int>) =
    match xs with
    |[]   -> []
    |[a] -> [a]
    |(x::xs) ->
        let smaller= QuickSort(xs |>List.filter(fun e->e<=x))
        let larger = QuickSort(xs |>List.filter(fun e->e>=x))
        smaller @ [x]@ larger

               
let data =[3;2;1;5]
let r= QuickSort data

你可能感兴趣的:(F#)