dimanche 5 avril 2015

How to use same tree after use it in same function in Haskell Recursive Function


data HuffmanTree
= Empty
| Intermediate Integer HuffmanTree HuffmanTree
| Leaf Char Integer
deriving (Show,Eq)

decode :: HuffmanTree -> [Char] -> [Char]
decode (Intermediate n x y) (z:zs) =
if ..... (some checks for x,y,z).....
then [getChar x] ++ (decode (Intermediate n x y) zs)


in this function I m moving on a tree. At "then" part I take deepest Leaf's x and after "++" I should give whole input tree again.The problem is : After ++ part still my function accepts my current tree (deepest leaf's parent). How to fix it ?


Aucun commentaire:

Enregistrer un commentaire