Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stringBuilder :: Tree -> [Char] -> [Char]
- stringBuilder t s = snd (decode t s [])
- -- Take the current tree, the current input string, and the current output
- -- string, return the remainder of the inpupt string and the modified output
- -- string
- decode :: Tree -> [Char] -> [Char] -> ([Char], [Char])
- decode (Leaf c) i o = (i, o ++ [c]) -- You only need one case here
- decode (Branch a b) (i:is) o =
- case i of
- '0' -> decode a is o
- '1' -> decode b is o
- _ -> undefined
- decode (Branch a b) [] o = ([], o)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement