Tree traversal: Difference between revisions
m
→Data.Tree nodes: Replacing <lang> with <syntaxhighlight> manually ... (does automation look feasible ?)
m (→Data.Tree nodes: Replacing <lang> with <syntaxhighlight> manually ... (does automation look feasible ?)) |
|||
Line 5,365:
Int -> [Int] -> Int
nodeCount = const (succ . sum)
treeDepth = const (succ . foldr max 1)
treeMax x xs = maximum (x : xs)
treeMin x xs = minimum (x : xs)
treeProduct x xs = x * product xs
treeSum x xs = x + sum xs
treeWidth _ [] = 1
treeWidth _ xs = sum xs
|