Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Immutable "stack"
- module Stack =
- let private emptyError () = failwith "empty"
- let push e list = e :: list
- let pop = function
- | _ :: xs -> xs
- | _ -> emptyError()
- let top = function
- | x :: _ -> x
- | _ -> emptyError()
- []
- |> Stack.push "x"
- |> Stack.push "y"
- |> Stack.push "z"
- |> Stack.pop
- |> Stack.top
- |> printfn "top value: %s"
Advertisement
Add Comment
Please, Sign In to add comment