data Tree = Leaf {} | Node { left :: Tree , key :: Int, right :: Tree } nodes :: Tree -> Int nodes t = case t of Leaf {} -> 0 Node {} -> nodes (left t) + 1 + nodes (right t)
Zusammenhang:
Datentyp | Funktion |
zwei Konstruktoren | zwei Zweige |
rekursiv (Tree → Tree) | rekursiv (nodes → nodes) |