Java: Integer square(Integer x) { if (x == null) return null; int i = x.intValue(); return new Integer(i * i); } SML: fun square(x : int option) : int option { case x of NONE => NONE | SOME(i) => SOME(i * i)