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