(* This code extends 'mini_prelude'. *) let rec mrg v7 = (fun v8 -> (fun v9 -> (match v8 with Nil -> (match v9 with Nil -> Nil | (Cons (v2, v1)) -> (Cons (v2, v1))) | (Cons (v6, v5)) -> (match v9 with Nil -> (Cons (v6, v5)) | (Cons (v4, v3)) -> (if ((v7 v6) v4) then (Cons (v6, (((mrg v7) v5) (Cons (v4, v3))))) else (Cons (v4, (((mrg v7) (Cons (v6, v5))) v3)))))))) ;; let empty = (Pair (0, Nil)) ;; let rec add_seg v1 = (fun v2 -> (fun v3 -> (fun v4 -> (if ((v4 mod 2) <= 0) then (Cons (v2, v3)) else ((((add_seg v1) (((mrg v1) v2) (HD v3))) (TL v3)) (v4 / 2)))))) ;; let add = (fun v3 -> (fun v4 -> (fun v5 -> (match v5 with (Pair (v2, v1)) -> (Pair ((v2 + 1), ((((add_seg v3) (Cons (v4, Nil))) v1) v2))))))) ;; let rec mrg_all v3 = (fun v4 -> (fun v5 -> (match v5 with Nil -> v4 | (Cons (v2, v1)) -> (((mrg_all v3) (((mrg v3) v4) v2)) v1)))) ;; let sort = (fun v3 -> (fun v4 -> (match v4 with (Pair (v2, v1)) -> (((mrg_all v3) Nil) v1)))) ;;