Last active
November 11, 2015 07:35
-
-
Save bryangarza/cc3f247778a0e8eca1b3 to your computer and use it in GitHub Desktop.
This file contains 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
open Printf | |
let fetch_ints (size : int) : int array = | |
Array.init size (fun x -> read_int()) | |
let insertion_sort = | |
let size = read_int() in | |
let sizep = pred size | |
and arr = fetch_ints size in | |
let x = arr.(sizep) in | |
let rec i_s arr i = | |
let ip = i-1 in | |
if arr.(ip) > x then ( | |
arr.(i) <- arr.(ip); | |
Array.iter (printf "%d ") arr; | |
Printf.printf "\n"; | |
i_s arr ip | |
) else ( | |
arr.(i) <- x; | |
Array.iter (printf "%d ") arr | |
); | |
in i_s arr sizep;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment