(* This code extends 'mini_prelude'. *) type ('a) heap = Tree of 'a * (('a) heap) list | Empty ;; let empty = Empty ;; let is_empty = (fun v3 -> (match v3 with Empty -> true | (Tree (v2, v1)) -> false)) ;; let merge = (fun v8 -> (fun v9 -> (fun v10 -> (fun v7 -> (match v10 with Empty -> (match v7 with Empty -> Empty | (Tree (v2, v1)) -> (Tree (v2, v1))) | (Tree (v6, v5)) -> (match v7 with Empty -> (Tree (v6, v5)) | (Tree (v4, v3)) -> (if ((v9 (v8 v6)) (v8 v4)) then (Tree (v6, (Cons ((Tree (v4, v3)), v5)))) else (Tree (v4, (Cons ((Tree (v6, v5)), v3))))))))))) ;; let insert = (fun v1 -> (fun v3 -> (fun v4 -> (fun v2 -> ((((merge v1) v3) (Tree (v4, Nil))) v2))))) ;; let rec merge_pairs v5 = (fun v6 -> (fun v7 -> (match v7 with Nil -> Empty | (Cons (v4, v3)) -> (match v3 with Nil -> v4 | (Cons (v2, v1)) -> ((((merge v5) v6) ((((merge v5) v6) v4) v2)) (((merge_pairs v5) v6) v1)))))) ;; let find_min = (fun x1 -> (match x1 with Empty -> (raise (Match_failure (string_of_bool true, 0, 0))) | (Tree (v2, v1)) -> v2)) ;; let delete_min = (fun x1 -> (fun x2 -> (fun x3 -> (match x3 with Empty -> (raise (Match_failure (string_of_bool true, 0, 0))) | (Tree (v2, v1)) -> (((merge_pairs x1) x2) v1))))) ;;