Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let r_quicksort l =
  2.     let split list pivot =
  3.       let rec _split inf sup = function
  4.         | [] -> (inf, sup)
  5.         | h :: t ->
  6.           if h < pivot then _split (h :: inf) sup t
  7.           else              _split inf (h :: sup) t
  8.       in _split [] [] list
  9.     in
  10.  
  11.     let rec sort result = function
  12.       | [] -> result
  13.       | [a] -> a :: result
  14.       | pivot :: t -> let (inf, sup) = split t pivot in sort (pivot :: (sort result inf)) sup
  15.  
  16.     in List.rev (sort [] l)
  17.     ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement