Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data Queue a = Queue [a] [a] -- front & back lists
- insert :: a -> Queue a -> Queue a
- insert x (Queue f b) = Queue f (x:b)
- pop :: Queue a -> (Maybe a, Queue a)
- pop (Queue [] []) = (Nothing, Queue [] [])
- pop (Queue (x:xs) b) = (Just x, Queue xs b)
- pop (Queue [] b) = pop $ Queue (reverse b) []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement