(* This code extends 'mini_prelude'. *) type ('a) queue = Queue of int * ('a) list * int * ('a) list ;; let empty = (Queue (0, Nil, 0, Nil)) ;; let is_empty = (fun v5 -> (match v5 with (Queue (v4, v3, v2, v1)) -> (v4 <= 0))) ;; let checkf = (fun v5 -> (match v5 with (Queue (v4, v3, v2, v1)) -> (if (v2 <= v4) then (Queue (v4, v3, v2, v1)) else (Queue ((v4 + v2), ((APPEND v3) (REVERSE v1)), 0, Nil))))) ;; let snoc = (fun v5 -> (fun v6 -> (match v5 with (Queue (v4, v3, v2, v1)) -> (checkf (Queue (v4, v3, (v2 + 1), (Cons (v6, v1)))))))) ;; let head = (fun x -> (match x with (Queue (v6, v5, v4, v3)) -> (match v5 with Nil -> (raise (Match_failure (string_of_bool true, 0, 0))) | (Cons (v2, v1)) -> v2))) ;; let tail = (fun x -> (match x with (Queue (v6, v5, v4, v3)) -> (match v5 with Nil -> (raise (Match_failure (string_of_bool true, 0, 0))) | (Cons (v2, v1)) -> (checkf (Queue ( (let k = (v6 - 1) in (if (k < 0) then 0 else k)), v1, v4, v3)))))) ;;