Answers for "how to randomize an array in delphi"

0

shuffle array delphi

procedure FastPermuteArray(A: TDynIntegerArray);
  procedure Swap(n, m: integer);
  var
    tmp: integer;
  begin
    tmp := A[n];
    A[n] := A[m];
    A[m] := tmp;
  end;
var
  i: Integer;
begin
  for i := High(A) downto 1 do
    Swap(i, RandomRange(0, i));
end;
Posted by: Guest on October-23-2020

Code answers related to "how to randomize an array in delphi"

Browse Popular Code Answers by Language