OK... last sort of the day and probably the most fun. F# is really awesome.
let rec quickSort list =
match list with
| [] -> []
| [x] -> [x]
| hd :: _ ->
quickSort (List.filter (fun x -> x < hd) list) @ hd :: quickSort (List.filter (fun x -> x > hd) list)
[<EntryPoint>]
let main args =
printfn "%s" (List.fold (fun acc x -> acc + " " + x.ToString()) "" (quickSort [10; 7; 1; 0; -1; 9; 33; 12; 6; 2; 3; 33; 34;]))
0
let me know How I can improve this code. I am trying to think functionally and want my program to be most efficient, concise and functional.
x !< hd
andx !> hd
\$\endgroup\$Task
s for that. Something likeTask.Run(fun () -> quickSort ...)
to start twoTask
s and then callResult
on both of them to get the results. \$\endgroup\$