Haskell 哈夫曼译码调试
当我调试哈夫曼解码函数时Haskell 哈夫曼译码调试,haskell,tree,decoding,huffman-code,Haskell,Tree,Decoding,Huffman Code,当我调试哈夫曼解码函数时 decode :: (Tree a, [Bit]) -> [a] decode (tree, list) = case list of [] -> case tree of Leaf pos a -> replicate_Pos pos a _ -> (num_only (follow_bit_path_to_one_value tree list)): huffman_decode (tree, (list_only (follow
decode :: (Tree a, [Bit]) -> [a]
decode (tree, list) = case list of
[] -> case tree of
Leaf pos a -> replicate_Pos pos a
_ -> (num_only (follow_bit_path_to_one_value tree list)): huffman_decode (tree, (list_only (follow_bit_path_to_one_value tree list))
where
num_only :: (a, [Bit]) -> a
num_only (a, _) -> a
list_only:: (a, [Bit]) -> [Bit]
list_only (_, list) -> list
它在输入“where”时出现了一个解析错误?我哪里做错了?这段代码的真正问题是括号不匹配,而不是大小写表达式中的缩进。此外,还有箭头,而不是
=
登录帮助程序函数
下面的代码解析得很好
decode :: (Tree a, [Bit]) -> [a]
decode (tree, list) = case list of
[] -> case tree of
Leaf pos a -> replicate_Pos pos a
_ -> (num_only (follow_bit_path_to_one_value tree list)): huffman_decode (tree, (list_only (follow_bit_path_to_one_value tree list)))
where
num_only :: (a, [Bit]) -> a
num_only (a, _) = a
list_only:: (a, [Bit]) -> [Bit]
list_only (_, list) = list