How can I write a function which receives a list, for example [7, 8, 9]
.
The function has inside an infinite list. It will calculate all divisors from an infinite list.
For example take 5 (f [7, 8, 9])
output will be [7, 8, 9, 14, 16]
Second example take 7 (f [7, 8, 9])
output will be [7, 8, 9, 14, 16, 18, 21]
I hope you can understand what I mean.
My code looks like this:
myFunction list = [x | x <- [1..], el <-[list], x `mod` el == 0]
My code works only with constant list. If I write
myFunction list = [x | x <- [1..], el <-[7, 8], x `mod` el == 0]
It works only for 7 and 8
How can I pass an arbitrary list?