Skip to content

Instantly share code, notes, and snippets.

@jdpage
Created March 28, 2012 02:58
Show Gist options
  • Save jdpage/2223160 to your computer and use it in GitHub Desktop.
Save jdpage/2223160 to your computer and use it in GitHub Desktop.
Quicksort in F#
open System
let rec sorted = function
| (x :: xs) ->
let left, right = List.partition (fun i -> i < x) xs
let sleft = sorted left
let sright = sorted right
sleft @ (x :: sright)
| [] -> []
let rnd = new Random()
let l = [for i in [1 .. 100] -> rnd.Next(1, 1000)]
printfn "%A" l
printfn "%A" <| sorted l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment