Wiederholung: Kompositum

Haskell: algebraischer Datentyp

data Tree a = Leaf a 
            | Branch (Tree a) (Tree a)
    Leaf   :: a -> Tree a
    Branch :: Tree a -> Tree a -> Tree a

Java: Kompositum

interface Tree<A> { }
class Leaf<A> implements Tree<A> { A key; }
class Branch<A> implements Tree<A> {
    Tree<A> left; Tree<A> right;
}

(Scala: case class)



Johannes Waldmann 2014-07-10