Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Standard ML - Filter and mod

  1. Sep 21, 2011 #1
    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.
     
    Last edited: Sep 21, 2011
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Standard ML - Filter and mod
  1. C Standards (Replies: 6)

Loading...