树遍历的实现:预订

时间:2017-10-03 19:32:16

标签: haskell tree-traversal

我必须实现预订树遍历: (Knoten'A'(Blatt'B')(Blatt'C'))的结果必须是['A','B','C']

这是我的代码,但我无法找到错误:

data Baum a = Blatt a | Knoten a 
                           (Baum a)
                           (Baum a)

preorder (Blatt () ) = []
preorder (Knoten a l r) = [a] ++ preorder l ++ preorder r

0 个答案:

没有答案