Previous Up Next

9.6.2  Pour sortir d’une boucle : break

break n’a pas d’argument ni parenthèse.
break permet de sortir d’une boucle.
On tape :

testbreak(a,b):={
local r;
while (1==1){
  if (b==0){break;} 
  r:=irem(a,b);
  a:=b;
  b:=r;
}
return a;
}

puis on tape :

testbreak(4,0)

On obtient :

4 car il y a eu l’interruption de la boucle while quand b==0

Previous Up Next