(* * This file contains an assoc function equivalent to that in alist.ml, but * here the definition of assoc is in "minimalist" form. I.e., here we exploit * ML's type inference capabilities to avoid any explicit type declarations. *) fun assoc(key, al) = if al = nil then ("", 0) (* NOTE: try "then nil" here *) else if key = #1(hd(al)) then hd(al) else assoc(key, tl(al)); (* * Simple tests of the alist functions. *) val a = [("x",10),("y",20),("z",30)]; #2(assoc("x", a)); #2(assoc("z", a)); #2(assoc("w", a));