This file contains 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
yourstring.[i] ;; (* retourne le caractère de rang i de ta chaîne de caractères *) | |
"exemple".[4] ;; | |
(* - : char = 'p' *) | |
(* le rang va de 0 à (n-1), attention ! *) | |
String.make n char ;; (* construit à partir de ton caractère char une string longue de n caractères *) | |
String.make 1 'e' ;; | |
(* - : string = "e" *) |
This file contains 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
(* ---3.2 char list list...--- *) | |
let rec sentence_to_single_list morse_sentence = match morse_sentence with | |
|[] -> [] | |
|[]::sentence -> '/' :: sentence_to_single_list sentence (* on ajoute un '/' si le mot est fini *) | |
|([]::word)::sentence -> ' ' :: sentence_to_single_list (word::sentence) (* on ajoute un espace ' ' si la lettre est finie *) | |
|((e::letter)::word)::sentence -> e :: (sentence_to_single_list ((letter::word)::sentence)) ;; (* on extrait un caractère d'une lettre en morse pour le mettre dans notre liste *) | |
(* val sentence_to_single_list : char list list list -> char list = <fun> *) | |
sentence_to_single_list (sentence_to_morse [['y'; 'o']; ['d'; 'a'; 'w'; 'g']]) ;; |
This file contains 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
(* --- 3.1 Cellule --- *) | |
let get_cell (x, y) board = | |
let rec row list n = match (list, n) with (* this function reads the y value of the row sent by column *) | |
|[], _ -> invalid_arg "y coordinate doesn't exist !" | |
|e::l, 1 -> e (* return the cell value *) | |
|e::l, n -> row l (n-1) | |
in let rec column board n = match (board, n) with (* this function sends the correct row (our 'int list' inside our 'list') to the 'row' function *) | |
|[], _ -> invalid_arg "x coordinate doesn't exist !" | |
|e::l, 1 -> row e y (* when column reaches the correct n, it sends the selected row to the 'row' function along with the y parameter *) |
This file contains 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
type 'a bundle = | |
| Empty | |
| Item of 'a * 'a bundle | |
;; | |
let empty_bundle () = Empty ;; | |
let cons bundle element = Item (element, bundle);; |
This file contains 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
def sumDivs(n,accu, i): | |
if i > (n//2): | |
return accu | |
elif n % i == 0: | |
print(i) | |
return sumDivs (n, accu + i , i+1) | |
else : | |
return sumDivs (n, accu, i+1) | |
This file contains 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
def checkValidlist9AB(n): | |
a = n // 10 | |
b = n % 10 | |
return (a != b) | |
def checkValidlist9(n): | |
return (n > 9 and n < 100) | |
This file contains 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
false || (1/0 = 0);; | |
true || (1/0 = 0);; | |
false && (1/0 = 0);; | |
true && (1/0 = 0);; | |
'Z' < 'a';; | |
"A long sentence to see how string comparisons work" > "a little one";; | |
(* to see how functions with several parameters work *) |
This file contains 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
### Correction des fonctions du lundi 19/09 ### | |
def print_mat(M, d): | |
s = "| {:" + str(d) + "d}" | |
l = len(M[0]) | |
t = '-' * (d+3) * l + '-' | |
for i in range(len(M)): | |
print(t) | |
for j in range(l): | |
print(s.format(M[i][j]), end=' ') |
This file contains 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
def rotateMatrix(matrix): | |
newMatrix = [] | |
l = len(matrix) | |
for i in range(l): | |
newMatrix.append([]) | |
for j in range(l): | |
newMatrix[i].append(matrix[l - 1 - j][i]) | |
return newMatrix |
This file contains 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
#!/bin/sh | |
# EX 1 | |
perl -0777 -pe 's/{.*}/COMMENTAIRE/gsm' exo1/q1 | |
perl -0777 -pe 's/{[^}]*}/COMMENTAIRE/gsm' exo1/q2 | |
# EX 2 | |
perl -0777 -pe 's/"[^"]*"/CHAINE/gsm' exo2/q1 | |
perl -0777 -pe 's/"([^"\\]|\\.)*"/CHAINE/gsm' exo2/q2 |
OlderNewer