RosettaCodeData/Task/Queue-Definition/Standard-ML/queue-definition-2.ml

17 lines
234 B
OCaml
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
structure Queue:> QUEUE =
struct
type 'a queue = 'a list
val empty_queue = nil
exception Empty
fun enq q x = q @ [x]
fun deq nil = raise Empty
| deq (x::q) = (x, q)
fun empty nil = true
| empty _ = false
end;