(* This code extends 'mini_prelude'. *) type ('a) queue = Queue of ('a) list * ('a) list * ('a) list ;; let empty = (Queue (Nil, Nil, Nil)) ;; let is_empty = (fun v6 -> (match v6 with (Queue (v5, v4, v3)) -> (match v5 with Nil -> true | (Cons (v2, v1)) -> false))) ;; let rec rotate x = (match x with (Queue (v9, v8, v7)) -> (match v9 with Nil -> (match v8 with Nil -> (raise (Match_failure (string_of_bool true, 0, 0))) | (Cons (v2, v1)) -> (Cons (v2, v7))) | (Cons (v6, v5)) -> (match v8 with Nil -> (raise (Match_failure (string_of_bool true, 0, 0))) | (Cons (v4, v3)) -> (Cons (v6, (rotate (Queue (v5, v3, (Cons (v4, v7)))))))))) ;; let exec = (fun v7 -> (match v7 with (Queue (v6, v5, v4)) -> (match v4 with Nil -> (let v1 = (rotate (Queue (v6, v5, Nil))) in (Queue (v1, Nil, v1))) | (Cons (v3, v2)) -> (Queue (v6, v5, v2))))) ;; let snoc = (fun v4 -> (fun v5 -> (match v4 with (Queue (v3, v2, v1)) -> (exec (Queue (v3, (Cons (v5, v2)), v1)))))) ;; let head = (fun x -> (match x with (Queue (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 (v5, v4, v3)) -> (match v5 with Nil -> (raise (Match_failure (string_of_bool true, 0, 0))) | (Cons (v2, v1)) -> (exec (Queue (v1, v4, v3)))))) ;;