Wiederholung Kompositum

Haskell: algebraischer Datentyp

data List a  = Nil | Cons a (List a)
     Nil  :: List a
     Cons :: a -> List a -> List a
Java: Kompositum
interface List<A> { }
class Nil implements List<A> { }
class Cons<A> implements List<A> {
    A head; List<A> tail;
}
implementieren/testen:
public class Main {
  List<Integer> range(from,to) { .. }
  public static void main(String[] args) {
    List<Integer> l = Main.range(0,10);
  }
}



2009-06-15