我有以下数据类型
data Tree a -> Node a [Tree a]
并希望找到所有节点的标签和树的高度。
这是我所做的:
height:: Tree a -> Integer height
(Node _ (x:xs)) = 1 + maximum height' (x:xs)
height' (x:xs) = map height (x:xs)
Run Code Online (Sandbox Code Playgroud)
我希望height'会返回映射到x:xs的高度列表,并尝试查找该值的最大值,但ghci不赞成此处的map函数。