Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Stack =
- | Empty
- | Stack of String list
- let push item deck =
- match deck with
- | Empty -> Stack [item]
- | Stack d -> Stack (item::d)
- let pop (Stack d) =
- match d with
- | h::[] -> h,Empty
- | h::t -> h,(Stack t)
- let empty = Empty
- let s,st = pop empty
- let pop stack =
- match stack with
- | Empty -> None, Empty
- | Stack (h::[]) -> Some h,Empty
- | Stack (h::t) -> Some h,(Stack t)
- let pop stack =
- match stack with
- | Empty -> Error "Empty Stack"
- | Stack (h::[]) -> Ok (h,Empty)
- | Stack (h::t) -> Ok (h,(Stack t))
Add Comment
Please, Sign In to add comment