structure Complex =
struct
type t = real * real;
val zero = (0.0, 0.0);
val i = (0.0, 1.0);
fun sum ((x, y), (x', y')) = (x+x', y+y') : t;
fun diff ((x, y), (x', y')) = (x-x', y-y') : t;
fun prod ((x, y), (x', y')) = (x*x' - y*y', x*y' + x'*y) : t;
fun recip ((x, y), (x', y')) = let val t = x*x' + y*y'
in (x/t, ~y/t) end;
fun quo (z, z') = prod(z, recip z');
end;
val a = (0.3, 0.0);
val b = Complex.sum(a, Complex.i);
val c = Complex.sum(b, (0.7, 0.0));
val d = Complex.prod(c, c);sml_tk
is a Standard ML package providing a portable, typed and abstract interface to the user interface description and command language Tcl/Tk. It allows the implementation of graphical user interfaces in a structured and reusable way, supported by the powerful module system of Standard ML.
