daily pastebin goal
71%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. type Stack =
  2. | Empty
  3. | Stack of String list
  4.    
  5. let push item deck =
  6.     match deck with
  7.     | Empty -> Stack [item]
  8.     | Stack d -> Stack (item::d)
  9.    
  10. let pop (Stack d) =
  11.     match d with
  12.     | h::[] -> h,Empty
  13.     | h::t -> h,(Stack t)
  14.    
  15. let empty = Empty
  16. let s,st = pop empty
  17.    
  18. let pop stack =
  19.     match stack with
  20.     | Empty -> None, Empty
  21.     | Stack (h::[]) -> Some h,Empty
  22.     | Stack (h::t) -> Some h,(Stack t)
  23.    
  24. let pop stack =
  25.     match stack with
  26.     | Empty -> Error "Empty Stack"
  27.     | Stack (h::[]) -> Ok (h,Empty)
  28.     | Stack (h::t) -> Ok (h,(Stack t))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top