RndPermutation(Value: Integer): Array;
Value. Array length.
The RndPermutation method performs pseudorandom permutation of an array.
Value of the Value parameter must not be greater than 0.
To execute the example, add a link to the MathFin system assembly.
Sub UserProc;
Var
i, n, m: integer;
mathrnd, mathrnd1: array Of integer;
Begin
n := 8;
m := 3;
mathrnd := math.RndSample(n, m);
mathrnd1 := math.RndPermutation(n);
If mathrnd <> Null Then
Debug.WriteLine("Array sample");
For i := 0 To math.RndSample(n, m).Length - 1 Do
Debug.WriteLine(mathrnd[i]);
End For;
Else Debug.WriteLine(math.ErrorMsg);
End If;
Debug.WriteLine("Permutation of numbers in the array");
If mathrnd1 <> Null Then
For i := 0 To math.RndPermutation(n).Length - 1 Do
Debug.WriteLine(mathrnd1[i]);
End For;
Else Debug.WriteLine(math.ErrorMsg);
End If;
End Sub UserProc;
After executing the example the array that has the length of N numbers is built. The M of numbers is randomly selected from the obtained array. Numbers in the source array are randomly permuted. The obtained arrays are displayed in the console window.
See also: