Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data Bag = String [Bag]
- head :: String -> Bag
- head s = s []
- join :: String -> String -> Bag -> Bag
- join p d (x xs) =
- if p /= x && notElem p xs
- then x xs
- else if p == x
- then x xs:(d [])
- else x (take elementBag xs):((y (_ zs) -> (_ zs:d)) d xs!!elementBag):(drop elementBag+1 xs)
- where elementBag = length (takeWhile ((y _) -> y = p) xs)
Add Comment
Please, Sign In to add comment