Hello, I need to implement a function for the Eratosthenes sieve.
I already have a function
removep p l
which removes elements lthat match the predicate pand function
nats
which returns an endless list of natural numbers, and I have to use both in my solution.
Now I understand how the sieve works, but it seems that I am having problems with this.
I am doing something like this:
sieve = (drop 1 nats)
where
sieve (h:t) = h : (removep (\x -> (mod x p) == 0) t) : sieve
but this does not seem to work. Any help? Also note that this is an appointment, so if possible, do not give out the exact solution. I'd rather get an idea of ββwhat I'm doing wrong and how I need to change it. Thanks in advance.