Document last modified:
union ( [(1, "a"), (1, "b"), (1, "c")], [(1, "a"), (1, "x"), (2, "c")]);
[(1, "b"), (1, "c"), (1, "a"), (1, "x"), (2, "c")]
fun member (_,[]) = false
| member (a,(h::t)) =
if a=h then true
else member (a, t);
fun union ([],L) = L
| union ((h::t),L) =
if member(h,L) then union(t,L)
else h::union(t,L);
fun amount [] = 0
| amount ((R h)::t) = (trunc h) + amount t
| amount ((I h)::t) = h + amount t
| amount ((S "dollar")::t) = 100+amount t
| amount ((S "nickel")::t) = 5 +amount t
| amount ((C dollar)::t) = 100 +amount t
| amount ((C half)::t) = 50 +amount t
| amount ((C quarter)::t) = 25 +amount t
| amount ((C dime)::t) = 10 +amount t
| amount ((C nickel)::t) = 5 +amount t
| amount ((C penny)::t) = 1 +amount t;