- #1
azrarillian
- 1
- 0
Hi, I'm using SML and I'm trying to make a program/function that finds all the prime numbers in an Int list of numbers.
what I'm trying to do is make a function that removes any (and all) elements x of the int list where x mod p = 0, and where p is the first prime number (2).
then i want to make a recursion so that it does the same for the next element after p, which should be a prime number.
the only problem i have is that i don't know how to filter or delete the elements x in the list. I've tried to use the function 'filter' but I can't figure out how to take modulo of the tail of the list (or rather of the elements in the tail) and the prime number.
please help...
also, I know that there are other ways to find primenumbers, and though this is the way i want to use (for now) any and all help, otherwise, is welcome.
what I'm trying to do is make a function that removes any (and all) elements x of the int list where x mod p = 0, and where p is the first prime number (2).
then i want to make a recursion so that it does the same for the next element after p, which should be a prime number.
the only problem i have is that i don't know how to filter or delete the elements x in the list. I've tried to use the function 'filter' but I can't figure out how to take modulo of the tail of the list (or rather of the elements in the tail) and the prime number.
please help...
also, I know that there are other ways to find primenumbers, and though this is the way i want to use (for now) any and all help, otherwise, is welcome.
Last edited: