\begin{slide}{Funktionen auf Alg. Datentypen}

\begin{verbatim}
data Node k = Leaf   { key :: k }
    | Branch { key :: k, left :: Node k, right :: Node k }
\end{verbatim}
(vollst.) Fallunterscheidung nach den Konstruktoren:
\begin{verbatim}
children :: Node k -> [ Node k ]
children = \ n -> case n of
    Branch {} -> [ left n, right n ]
    Leaf   {} -> [ ]
\end{verbatim}
alternative Schreibweise: \emph{pattern matching}
\begin{verbatim}
children = \ n -> case n of
    Branch { left = l, right = r } -> [ l, r ]
    Leaf   { } -> [ ]
\end{verbatim}  

\end{slide}
