{- Merge two sorted lists -}
merge (x:xs) (y:ys)
| x < y = x: merge xs (y:ys)
| x > y = y: merge (x:xs) ys
| x == y = x: merge xs ys
merge [] ys = ys
merge xs [] = xs
{-- Generic Hamming sequence on a list of factors. --}
genHam :: [Integer]->[Integer]
genHam [] = []
genHam (x:xs) = out
where
out = merge ( 1: map (*x) out) (genHam xs)
{- Usage:
take 10 (genHam [2,3,5])
-}