fun zip ([], _) = [] | zip (_, []) = [] | zip (x::xs, y::ys) = (x,y)::(zip(xs,ys)); fun unzip [] = ([],[]) | unzip ((x,y)::pairs) = let val (xs,ys) = unzip pairs in (x::xs, y::ys) end ;