Listen

eigentlich:

data List a = Nil {}
    | Cons { head :: a, tail :: List a }
aber aus historischen Gründen: List a = [a], Nil = [], Cons = (:)
data [a] = [] | (:) { head :: a, tail :: [a] }
Pattern matching dafür:
length :: [a] -> Int
length l = case l of
    []     -> 0
    x : xs -> ...



Johannes Waldmann 2011-01-18