1234567891011 |
- (* datatype example -- single and pair list *)
- datatype ('a, 'b) element =
- Pair of 'a * 'b
- | Single of 'a;
- fun sum_elem_list nil = 0
- | sum_elem_list (Single(x)::rest) = sum_elem_list rest
- | sum_elem_list (Pair(x, y)::rest) = y + (sum_elem_list rest);
- sum_elem_list [Pair ("in", 6), Single "function", Pair ("as", 2)];
|