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 list_of_string = fun | |
| | "" -> [] | |
| | s -> let n = string_length s in let t = sub_string s 1 (n-1) in | |
| s.[0]::( list_of_string t );; | |
| list_of_string "abcd";; | |
| let rec string_of_list = fun | |
| | [] -> "" | |
| | [x] -> string_of_char(x) | 
  
    
      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] | 
  
    
      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 takewhile p l = match (l, p (hd l)) with | |
| |([], _) -> [] | |
| |(_, false) -> [] | |
| |((h::q), true) -> h::(takewhile p q);; | |
| takewhile (fun x -> x>0) [8;5;-7;2;0;1];; | |
| let rec dropwhile p l = match (l, p (hd l)) with | |
| |([], _) -> [] | |
| |(l, false) -> l | 
  
    
      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 dicho v l = match (vect_length v) with | |
| |1 -> (v.(0) = l) | |
| |n -> if ((n mod 2) = 0) then ( | |
| if (v.(n/2) <= l) then (dicho (sub_vect v (n/2) (n/2)) l) | |
| else (dicho (sub_vect v 0 (n/2)) l);) | |
| else (if(v.(n-1) = l) then true else (dicho (sub_vect v 0 (n-1)) l));; | |
| dicho [|2;3;4;5|] 5;; | |
| (* (* (* (* (* *) *) *) *) *) | 
  
    
      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);; | 
  
    
      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 retourner ch = match string_length ch with | |
| 0 -> ch | |
| | n -> let sch = (sub_string ch 1 (n-1)) in (retourner sch)^(char_for_read(ch.[0]));; | |
| retourner "abcd";; | |
| let rec compl_aux ch ch2 = match string_length ch with | |
| 0 -> ch2 | |
| | n -> ( if (ch.[0] = `0`) then | |
| compl_aux (sub_string ch 1 (n-1)) (ch2^"1") | |
| else | 
  
    
      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 silv n = | |
| let u = make_vect (2*n+1) 0 in | |
| let k = ref 2 in let j = ref 3 in let p = ref 3 in | |
| u.(1)<- 1; u.(2)<-2; u.(3)<-2; | |
| while u.(n)==0 do | |
| for i=1 to !k do u.(!p+i) <- !j; done; | |
| p:=!p+(!k); j:=!j+1; k:=u.(!j); | |
| done; | |
| u;; | |
  
    
      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 tri e = | |
| let tmp = ref 0 in | |
| if (e.(0)<e.(2)) then (tmp:=e.(0); e.(0)<-e.(2); e.(2) <- !tmp); | |
| if (e.(1)<e.(0)) then (tmp:=e.(0); e.(0)<-e.(1); e.(1) <- !tmp); | |
| if (e.(2)<e.(1)) then (tmp:=e.(1); e.(1)<-e.(2); e.(2) <- !tmp); | |
| e;; | |
| let echange i j v = | |
| let tmp = ref 0 in | |
| tmp:=v.(i); v.(i)<-v.(j); v.(j)<-(!tmp); |