| re: dear prof tobot |
| [29729] by "max cooking" (ce-web1.wesleyan.edu)
on Tue 09 Dec 2003 21:07:42
[ reply ] [ up ]
|
- fun makelist 0 = nil
| makelist 1 = nil
| makelist x = x :: (makelist (x-1));
i don't want 2 include the 1 i guess cause if I am making a prime # list using makelist as a way 2 generate possible factors for a number i don't want 1 to b included bcause that will always hav a 0 remainder
AND
wow about that list stuff that is helpful!! thx prof
now i no how 2 check divisibility by 3, for example:
fun divthree x = x mod 3 = 0;
owo!! ok now could u plz teach me how 2 do this sort of thing w/ a list? like i want 2 make a prime test by doing something like (english is inside {{{{ }}}}):
fun prime 0 = "false"
| prime x =
if x mod {{{{any of the list of integers from 2 through x}}}} = 0
then "true"
else "false";
but this is totaly illegal of course so i need help!!! thx profesor |
|
|
|
| re: dear prof tobot |
| [29734] by "max cooking" (ce-web1.wesleyan.edu)
on Tue 09 Dec 2003 23:50:58
[ reply ] [ up ]
|
tobot i also figured this out 2
fun trydiv [] x = false
| trydiv (h::t) x =
if x mod h = 0
then true
else trydiv t x;
|
|
|
|
| re: dear prof tobot |
| [29735] by "max cooking" (ce-web1.wesleyan.edu)
on Wed 10 Dec 2003 00:12:05
[ reply ] [ up ]
|
wow i am ON A ROLL!! a test for primality:
fun prime 0 = false
| prime 1 = false
| prime x =
if trydiv (makelist (x-1)) x = true
then false
else true;
tobot i c y u njoy this so much!!!!!!!!!!! it is the awsomest when u make a function and dont get a error massage!!! |
|
|
|
| re: dear prof tobot |
| [29736] by "max cooking" (ce-web1.wesleyan.edu)
on Wed 10 Dec 2003 00:35:34
[ reply ] [ up ]
|
I am CONQUER!!!!
make a list of the first x primes:
- fun primelist 0 = []
| primelist x =
if prime x = true
then x :: (primelist (x-1))
else (primelist (x-1));
|
|
|
|