Go backward to
Record Types
Go up to
Top
Go forward to
Universal Quantification
Variant Types and Recursion
Example:
type AVar = [a: Int, b: String]
value v1: AVar = [a = 3]
value v2: AVar = [b = "abcd"]
value f = fun(x: AVar)
case x of
[a = anInt] "int"
[b = aString] "string" ^ aString
otherwise "error"
Recursive function definitions
rec value fact =
fun(n: Int) if n=0 then 1 else n*fact(n-1)
Recursive type definitions
rec type IntList =
[nil: Unit
cons: {head: Int, tail: IntList} ]
Author:
Wolfgang Schreiner
Last Modification: May 27, 1998