Structures
Package a set of declarations
structure Queue1 = struct
type ‘a T = ‘a list; (* T is conventional name *)
(* constructors)
val empty = nil;
fun enq x q = a @ [x]; (* @ is append *)
(* accessors *)
exception empty_queue;
fun head (x::q) = x
| head nil = raise empty_queue;
fun deq (x::q) = (x,q)
| deq nil = raise empty_queue;
Previous slide
Next slide
Back to first slide
View graphic version