Lab 7 Instructions #
Reminders #
Introduce yourself to your new lab group.
While other students are coming into class, follow the setup instructions below. (But please wait until you’re instructed before beginning work on the lab.)
Setup instructions #
Head to http://url.cs51.io/lab7 and follow the Lab Procedures.
Lab puzzle #
Today’s puzzle concerns the following signature for an integer queue module and its corresponding implementation, as presented in the textbook.
module type INT_QUEUE =
sig
type int_queue
val empty_queue : int_queue
val enqueue : int -> int_queue -> int_queue
val dequeue : int_queue -> int * int_queue
end ;;
module IntQueue : INT_QUEUE =
struct
type int_queue = int list
let empty_queue : int_queue = []
let enqueue (elt : int) (q : int_queue) : int_queue =
q @ [elt]
let dequeue (q : int_queue) : int * int_queue =
match q with
| [] -> raise (Invalid_argument "dequeue: empty queue")
| hd :: tl -> hd, tl
end ;;