\begin{slide}{Pattern Matching}

\begin{itemize}
\item Fallunterscheidung nach dem Konstruktor
\item Bindung von lokalen Namen
\end{itemize}

\begin{verbatim}
abstract class Term   // Scala
case class Constant (value : Int) 
    extends Term
case class Plus (left: Term, right : Term) 
    extends Term
def eval(t: Term): Int = {
  t match {
    case Constant(v) => v
    case Plus(l, r) => eval(l) + eval(r)
  } }
\end{verbatim}

\end{slide}
