@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let check : bool = true ; // suppose que c'est vrai | |||
assert ! (check == true) ; // vérifier l'erreur | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let check : bool = false ; // suppose que c'est faux | |||
assert ! (check == true) ; // vérifier l'erreur | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
println ! ("Bonjour, monde !") ; | |||
} |
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { // définit une fonction nommée main | |||
println ! ("Bonjour, monde ! ") ; | |||
/* println!( ) est une commande utilisée pour afficher du contenu ou du texte. | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let var = "OK" ; | |||
println! ("La valeur de var est : { }", var); | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let var : i32 = 100 ; | |||
let str : String = "Bonne".to_string() ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let x = 100 ; | |||
let y = 200 ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
const NUM : i32 = 100 ; | |||
fn main() { | |||
println ! ("La valeur de NUM est {}", NUM) ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let var1 : f32 = 100.88 ; | |||
let var2 : i32 = var1 as i32 ; // var1 devient i32 | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
funt(100, 200) ; // appelle la fonction | |||
} | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let num = funt(100) ; // appelle la fonction | |||
println ! ("La valeur de num est : { }", num) ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn foo() -> bool { // spécifier un type de retour | |||
return true // renvoie une valeur à l'appelant | |||
} | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let (x, y) = (100, 200) ; // liaison de variable | |||
println ! ("La valeur de x est {}", x) ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let mut a = 100 ; // liaison de variable | |||
let mut b = 200 ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let x = "hello".to_string() ; | |||
let y = String::from("hello") ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
println ! ("10 + 2 = {}", 10 + 2) ; | |||
println ! ("10 - 2 = {}", 10 - 2) ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
println ! ("true AND false is {}", true && false) ; | |||
println ! ("true OR false is {}", true || false) ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let x : i32 = 100 ; | |||
let y : i32 = 200 ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let mut a : [i32 ; 4] = [8 ; 4] ; // créer un tableau | |||
a[1] = 10 ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let a :[f32 ; 4] = [0.1, 0.2, 0.3, 0.4] ; // créer un tableau | |||
println ! ("{} {} {} {}",a[0],a[1],a[2],a[3]) | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let num=10 ; | |||
if num==10 { | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let x=100 ; | |||
let y=200 ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let num = if true { // instruction let-if | |||
100 | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let mut num=5 ; | |||
loop { // instruction de boucle | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
for num in 5..9 { // "5 .. 9" contient les nombres de 5 à 8 | |||
println ! ("Cela va durer {} heures", num) ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let mut num=0 ; | |||
while num<=8 { // instruction while | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let t = ("Nous nous levons à", 8,"Heures",true); // crée un tuple | |||
print!("{} {} {} {}\n",t.0,t.1,t.2,t.3 ) ; // accède aux éléments | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let num:i32 = 3 ; // expression donnée | |||
match num { | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
struct Member { // créer une structure | |||
id : i32, // member : type | |||
name : String, | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
struct Square { // crée une structure | |||
len : i32, | |||
wid : i32, | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
enum Langage { // définit un enum | |||
JS, // membre | |||
Rust, | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let x = String::from("E2L") ; // x est propriétaire de "E2L". | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let s =String::from("Il fait beau") ; // s est propriétaire | |||
// de "Il fait beau". | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let s=String :: from("Vive le Rust !"); | |||
let n=cal( &s ); // reference | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
mod mon_module { // définit un module | |||
pub fn test(){ // pub signifie attribut public | |||
println ! ("Bonjour mes amis ! ") ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
mod m1{ | |||
pub fn a(){ | |||
println ! ("module m1") ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
pub fn ex_fun() { | |||
println ! ("{}", "Texte externe") ; | |||
} |
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
mod ex6_3 ; // charge un fichier externe | |||
use ex6_3::ex_fun ; // charge une fonction externe | |||
fn main () { | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
mod mon_module { | |||
pub fn a() { // la fonction est publique | |||
println ! ("fonction a") ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
mod mon_module { | |||
pub fn a() { | |||
println ! ("fonction a") ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
mod sup_module{ // module parent | |||
fn a() -> i32 { | |||
100 | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let v = vec ![100, 200, 300, 400] ; // crée un vecteur | |||
println ! ("Le premier élément est : {}",v[0]) ; // accède au premier élément | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let v =vec ! [8 ; 3] ; // répété trois fois | |||
println ! ("Le premier élément est : {}",v[0]) ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let mut v=Vec::new() ; // crée un vecteur | |||
v . push('R') ; // définit R comme le premier élément du vecteur | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let num = 3 ; | |||
match num { | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let x = 3 ; | |||
match x { | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let x = 5 ; | |||
match x { | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let x : Option<bool> = Some(true) ; // paramètres génériques | |||
let y : Option<i32> = Some(10) ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
struct Circle{ // création d'une structure de type | |||
radius : f32, // membre de la structure | |||
} | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
struct Cercle{ // créez une structure de type | |||
rayon : f32, // membre de la structure | |||
} | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
pub trait Show { // définit un trait | |||
fn show(&self) ; // définition d'une méthode de trait | |||
} | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
struct Jeu { | |||
numero : i32, | |||
} | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main(){ | |||
let ma_fermeture = | num : i32 | { num+200 }; //crée une fermeture | |||
let num = 100 ; | |||
@@ -1,3 +1,20 @@ | |||
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry | |||
Ecole du Logiciel Libre : https://e2li.org/ | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or any | |||
later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program. If not, see <http://www.gnu.org/licenses/> | |||
*******************************************************************/ | |||
fn main() { | |||
let mut capacity = "Capacité du disque dur : 5000".to_string() ; | |||
{ | |||