This is some pseudo-code for showing the amazing power of lazy evaluation. This code was executable in the old versions of Caml where lazy data structures and rational numbers were available.

Formal series:
- serial developments are (infinite) lists of coefficients
- we assume we are working with rational numbers (p/q denotes a rational number, not the integer division)

(* Opposite of a formal serie *)

let rec uminus cs =
map (fun x -> -x) cs

(* Integration *)

let integrate s =
let rec intrec n cs = match cs with
c :: rest -> (c/(n+1)) :: (intrec (n+1) rest)
in intrec 0 s

(* The serie: (-1)n = [1; -1; 1; -1; ...] *)

let rec s1 = 1 :: (uminus s1)

(* Logarithm can be defined as the integral of s1, with 0 as constant term *)
(* [0; 1; -1/2; 1/3; -1/4; 1/7; -1/8; 1/9; ...]

let log1 = 0 :: integrate s1

(* Sine and cosine can be mutually recursively defined.
sin = [0; 1; 0; -1/6; 0; ...]
cos = [1; 0; -1/2; 0; 1/24; ...]
*)

let rec sin = 0 :: (integrate cos)
and     cos = 1 :: (integrate (uminus sin))