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