Skip to content
Snippets Groups Projects
Commit 91dda212 authored by Paul Iannetta's avatar Paul Iannetta Committed by Thomas Wood
Browse files

Added a 'stack module' to be paired with calc.ml

parent 3634c98f
No related branches found
No related tags found
No related merge requests found
open Stack
type expr =
| Const [@f value] of int
| Add [@f left, right] of expr * expr
......
type 'a stack =
| Nil
| Cons [@f value, stack] of 'a * 'a stack
let is_empty s = s === Nil
let push x stack = Cons(x, stack)
let pop stack =
match stack with
| Cons (x, xs) -> x
| Nil -> stuck "Empty list"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment