I have this function:
generatePrimes :: Integral a => a -> [a]
generatePrimes n = [i | i <- [2..], isPrime i]
I am trying to get the first n primes. I know that I can call the function in main
by using the take
function (and get the first n elements of the list), but I want to be able to have the function stop when it reaches n primes (inside the function), so that when it is called in main
such as:
generatePrimes 8
it will display a list with only the first 8 primes.