Previous Up Next

8.3.3  Tirage aléatoire sans remise de p objets parmi n : rand alea hasard

rand a dans ce cas, soit 2, soit 3 arguments.
Si rand a 2 arguments : les arguments sont un entier p et une liste L alors rand(p,L) renvoie, au hasard, p éléments de la liste L.
Si rand a 3 arguments : les arguments sont trois entiers p,min,max alors rand(p,min,max) renvoie, au hasard, p entiers de [min,..,max] On tape :

rand(3,["r","r","r","r","v","v","v"])

On obtient :

["r","r","v"]

On tape :

rand(2,1,10)

On obtient :

[3,7]

On tape :

rand(2,4,10)

On obtient :

[5,7]

Previous Up Next