Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
prog:theorie:iterations [09/10/2022 15:22]
thierry [PHP]
prog:theorie:iterations [31/10/2022 17:04] (Version actuelle)
thierry [Foreach]
Ligne 39: Ligne 39:
 end; end;
 </​code>​ </​code>​
 +=== Repeat Until ===
 +<code delphi Pascal>
 + a := 10;
 +   ​repeat
 +      writeln('​value of a: ', a);
 +      a := a + 1
 +   until a = 20;
 +</​code>​
 +
  
 ===== For...To ===== ===== For...To =====
Ligne 56: Ligne 65:
       ...       ...
   end;   end;
 +  ​
 +  // Variante DownTo
 +  for vI:= 200 downto 20 do
 +  begin
 +      ...
 +  end;
 +
 </​code>​ </​code>​
  
-===== For...In =====+===== Foreach ===== 
 +Equivalents ''​for...of''​ ou ''​for..in'''​ en javascript 
 +==== PHP ==== 
 +<code php php> 
 +foreach ($tickets as $ticket) { 
 +          ... 
 +        } 
 +</​code>​ 
 + 
 + 
 +===== For...In=====
 ==== Javascript ==== ==== Javascript ====
 === Avec un tableau === === Avec un tableau ===
Ligne 105: Ligne 131:
 Banane Banane
 </​code>​ </​code>​
 +
 +===== Contrôles des boucles =====
 +==== Pascal ====
 +=== Break ===
 +''​break''​ sort de la boucle
 +<code delphi Code>
 +   a := 10;
 +   ​while ​ a < 20 do
 +   
 +   begin
 +      writeln('​value of a: ', a);
 +      a:=a +1;
 +      if( a > 15) then break;
 +   end;
 +</​code>​
 +<code c Résultat>​
 +value of a: 10
 +value of a: 11
 +value of a: 12
 +value of a: 13
 +value of a: 14
 +value of a: 15
 +
 +</​code>​
 +=== Continue ===
 +''​continue''​ retourne au début de la boucle :
 +<code delphi Code>
 +   a := 10;
 +   ​repeat
 +      if( a = 15) then
 +      begin
 +         a := a + 1;
 +         ​continue;​
 +      end;
 +      writeln('​value of a: ', a);
 +      a := a+1;
 +   until ( a = 20 );
 +</​code>​
 +<code c Résultat>​
 +value of a: 10
 +value of a: 11
 +value of a: 12
 +value of a: 13
 +value of a: 14
 +value of a: 16
 +value of a: 17
 +value of a: 18
 +value of a: 19
 +
 +</​code>​
 +
 +
 +
 +
 +