Created
March 15, 2012 09:10
-
-
Save blackh/2043103 to your computer and use it in GitHub Desktop.
Colle 4
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 est_luka_aux = fun | |
| [x] s -> ( (s+x) = -1 ) | |
| |(h::q) s -> ( (s+h) >= 0 ) && (est_luka_aux q (s+h));; | |
| let est_luka l = est_luka_aux l 0;; | |
| est_luka [1;-1;1;-1;1;-1;-1] ;; | |
| [1;-1;-1;1;-1;1;1;1;-1;-1] | |
| let rec p = fun | |
| | [] -> [] | |
| | (1::-1::-1::q) -> -1::q | |
| | (h::q) -> h::(p q);; | |
| let rec is_luka = fun | |
| | [x] -> ( x = -1 ) | |
| | l -> let m = p(l) in | |
| if (list_length l = list_length m) then false else is_luka m;; | |
| is_luka [1;-1;1;-1;1;-1;-1];; | |
| est_luka [1;-1;1;-1;1;-1;-1];; | |
| let rec fils_aux = fun | |
| | [] l -> ([], l) | |
| | (h::q) l -> let v = rev(h::l) in | |
| if (est_luka v && est_luka q) then (v,q) else fils_aux q v;; | |
| let fils l = fils_aux (tl l) [];; | |
| fils [1;-1;1;-1;1;-1;-1];; | |
| let rec c_aux = fun | |
| | [] l -> l | |
| | (h::q) l -> c_aux q (h::l);; | |
| let cree l1 l2 = 1::(c_aux (rev(l1)) l2);; | |
| cree [-1;] [1;-1;1;-1;-1];; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment