Created
January 31, 2012 17:35
-
-
Save blackh/1711754 to your computer and use it in GitHub Desktop.
Colle 2 - Pliage
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 | |
| compl_aux (sub_string ch 1 (n-1)) (ch2^"0"); );; | |
| let complement ch = compl_aux ch "";; | |
| complement "0100011";; | |
| let rec dblv_aux ch n = match n with | |
| 1 -> ch | |
| | n -> dblv_aux (ch^"0"^complement(retourner(ch))) (n-1);; | |
| let dblv n = match n with | |
| 0 -> "" | |
| |1 -> "0" | |
| | n -> dblv_aux "0" n;; | |
| let inf n = match n with | |
| n when (n mod 2)=0 -> (n/2) mod 2 | |
| | n -> ((n-1)/2)/2 mod 2;; | |
| let rec inf n = match n with | |
| n when (n mod 2)=0 -> (n/2) mod 2 | |
| | n -> inf ((n-1)/2);; | |
| let quotient ch = | |
| let k = ref 0 in | |
| for i=0 to ((string_length ch)-2) do if (ch.[i]=`1`) k:=(!k)+2^i; done; | |
| !k;; | |
| II | |
| let present T p n = | |
| let b = make_vect (p+1) false in let d = ref true in let max = ref 0 in | |
| for j=1 to p do | |
| for i=0 to (n-1) do if (T.(i)=j & not(b.(j))) then (b.(j)<-true; (if !max < i then max:=i;)) done; | |
| done; | |
| for i=1 to p do if not(b.(i)) then d:=false; done; | |
| if !d then !max else 0;; | |
| let localise T p = | |
| let n = (vect_length T) in let r = (present T p n) in | |
| match r with | |
| 0 -> (n+1) | |
| | _ -> r;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment