Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let r_quicksort l =
- let split list pivot =
- let rec _split inf sup = function
- | [] -> (inf, sup)
- | h :: t ->
- if h < pivot then _split (h :: inf) sup t
- else _split inf (h :: sup) t
- in _split [] [] list
- in
- let rec sort result = function
- | [] -> result
- | [a] -> a :: result
- | pivot :: t -> let (inf, sup) = split t pivot in sort (pivot :: (sort result inf)) sup
- in List.rev (sort [] l)
- ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement