problem 004 in SML. All but Cartesian product.