restructure + lecutre 07
This commit is contained in:
96 files changed
+458
-4
No files matched your search
@@ -0,0 +1,37 @@
|
||||
type 'a t = 'a list;;
|
||||
|
||||
exception Empty
|
||||
|
||||
let empty = [];;
|
||||
|
||||
let is_empty q = q = [];;
|
||||
|
||||
let enqueue x q = q @ [x];;
|
||||
|
||||
let dequeue q =
|
||||
match q with
|
||||
| [] -> raise Empty
|
||||
| _ :: xs -> xs;;
|
||||
|
||||
let dequeue_opt q =
|
||||
match q with
|
||||
| [] -> None
|
||||
| _ :: xs -> Some xs;;
|
||||
|
||||
let front q =
|
||||
match q with
|
||||
| [] -> raise Empty
|
||||
| x :: _ -> x;;
|
||||
|
||||
let front_opt q =
|
||||
match q with
|
||||
| [] -> None
|
||||
| x :: _ -> Some x;;
|
||||
|
||||
let length q =
|
||||
List.length q;;
|
||||
|
||||
let of_list l = l;;
|
||||
|
||||
let to_list q = q;;
|
||||
|
||||
Reference in new issue
Block a user