Objective Caml version 3.08.4 # (* Algebraic Data Types *) type intlist = Nil | Cons of int * intlist;; type intlist = Nil | Cons of int * intlist # let rec sum l = match l with Nil -> 0 | Cons (i, l) -> i + sum l;; val sum : intlist -> int = # (* Polimorphic Algebraic Data Types *) type 'a list = Nil | Cons of 'a * 'a list;; type 'a list = Nil | Cons of 'a * 'a list # let rec poly_sum plus zero l = match l with Nil -> zero | Cons (hd, tl) -> plus hd (poly_sum plus zero tl);; val poly_sum : ('a -> 'b -> 'b) -> 'b -> 'a list -> 'b = # let sum_int = poly_sum (+) 0;; val sum_int : int list -> int = # let sum_float = poly_sum (+.) 0.0;; val sum_float : float list -> float = # let concat_strings = poly_sum (^) "";; val concat_strings : string list -> string = # let rec append l1 l2 = match l1 with Nil -> l2 | Cons(hd, tl) -> Cons (hd, append tl l2);; val append : 'a list -> 'a list -> 'a list = # let sum_lists l = poly_sum append Nil l;; val sum_lists : 'a list list -> 'a list = # (* Using the standard list constructors that come with OCaml *) [1];; - : int list = [1] # 0 :: 1 :: [];; - : int list = [0; 1] # let rec append l1 l2 = match l1 with [] -> l2 | hd :: tl -> hd :: (append tl l2);; val append : 'a list -> 'a list -> 'a list =