Algebraische Datentypen und Pattern Matching

ein Datentyp mit zwei Konstruktoren:

data List a 
   = Nil             -- nullstellig 
   | Cons a (List a) -- zweistellig
Programm mit Pattern Matching:
length :: List a -> Int
length xs = case xs of
    Nil       -> 0
    Cons x ys -> 1 + length ys
beachte: Datentyp rekursiv Programm rekursiv

append :: List a -> List a -> List a



Johannes Waldmann 2013-02-01