Advertisement
Guest User

stuffs

a guest
Apr 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. data Q elt = Construct [elt] [elt]
  2.  
  3. enqueue :: (Q a) -> a -> (Q a)
  4. enqueue (Construct f b) el = Construct f (b : el)
  5.  
  6. dequeue :: (Q a) -> Maybe (a, Q a)
  7. dequeue (Construct f b) =
  8. if length f > 0 then ((head f), Construct (tail f) b) else if length b == 0 then Nothing else ((head b_rev), Construct (tail b_rev) [])
  9. where
  10. b_rev = reverse b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement