Created
February 2, 2012 08:53
-
-
Save blackh/1722430 to your computer and use it in GitHub Desktop.
Colle 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let rec suppri_list test l = | |
| match (l, (if (l<>[]) then test (hd l) else false;)) with | |
| | ([], _) -> [] | |
| | (_, true) -> suppri_list test (tl l) | |
| | (_, false) -> (hd l)::(suppri_list test (tl l));; | |
| suppri_list (modulo 2) (init 10);; | |
| let modulo p n = ((n mod p)=0);; | |
| let rec init n = match n with | |
| 2 -> [2] | |
| | n -> n::(init (n-1));; | |
| let rec er_aux l = | |
| match l with | |
| | [] -> [] | |
| |[x] -> [x] | |
| | l -> (hd l)::(er_aux (suppri_list (modulo (hd l)) (tl l)));; | |
| let eratos n = | |
| let ent = rev(init n) in (er_aux ent);; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment