(* Carsten Schuermann *) (* The visitor pattern in ML is just foldr *) let val E = [5, 2] val N = foldr (fn (x, y) => x*x :: y) nil E val S = String.implode (foldr (fn (x, [c1, c2]) => c1 :: String.explode (Int.toString x) @ [c2] | (x, c :: s) => c :: String.explode (Int.toString x) @ #"," :: #" " :: s) [#"[", #"]"] E) in (N, S) end