Guest User

Untitled

a guest
Nov 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. data Bag = String [Bag]
  2.  
  3. head :: String -> Bag
  4. head s = s []
  5.  
  6. join :: String -> String -> Bag -> Bag
  7. join p d (x xs) =
  8. if p /= x && notElem p xs
  9. then x xs
  10. else if p == x
  11. then x xs:(d [])
  12. else x (take elementBag xs):((y (_ zs) -> (_ zs:d)) d xs!!elementBag):(drop elementBag+1 xs)
  13. where elementBag = length (takeWhile ((y _) -> y = p) xs)
Add Comment
Please, Sign In to add comment