Created
August 9, 2016 21:36
-
-
Save gsg/e319a68a65e96b16b33ca92df3ab5ca6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let partition a p = | |
let len = Array.length a in | |
let rec loop l r = | |
if r = len then l | |
else if p a.(r) then begin | |
let tmp = a.(l) in | |
a.(l) <- a.(r); | |
a.(r) <- tmp; | |
loop (l + 1) (r + 1) | |
end else | |
loop l (r + 1) | |
in | |
loop 0 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment