1 2 3 4 5 6 7
import Data.List (foldl') data Tree a = Node a [Tree a] deriving (Eq, Show) nnodes :: Tree a -> Int nnodes (Node _ xs) = 1 + (foldl' (+) 0 $ map nnodes xs)