learning F#, it seems pretty cool, favourite functional language so far.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415
  1. let rec quicksort list =
  2. match list with
  3. | [] -> [] // Empty list
  4. | firstEl::tail ->
  5. let smallerEls =
  6. tail
  7. |> List.filter (fun e -> e < firstEl)
  8. |> quicksort
  9. let larger =
  10. tail
  11. |> List.filter (fun e -> e >= firstEl)
  12. |> quicksort
  13. smallerEls @ [firstEl] @ larger
  14. printfn "%A" (quicksort [1;5;23;18;9;1;3])