Results 1 to 4 of 4

Thread: TStringArray.Randomize()

  1. #1
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default TStringArray.Randomize()

    Couldn't find anything like this, relatively simple and works for any array (probably). Let me know what I did wrong!

    Simba Code:
    function tStringArray.randomize(): tStringArray;
    var
      i:integer;
    begin
      for i:=0 to high(self) do
        _swap(self[i], self[random(low(self), high(self))], 2);
      exit(self);
    end;

  2. #2
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    From ogLivid:
    Simba Code:
    function tStringArray.shuffle():tStringArray;
    var
      vIndex:int32;
    begin
      for vIndex:=high(result:=self) downto 0 do
        system.swap(result[vIndex],result[random(vIndex+1)]);
      exit(result);
    end;

    Main difference, that one ^ will not alter the original array.




    Skype: obscuritySRL@outlook.com

  3. #3
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    Couldn't find anything like this
    https://github.com/SRL/SRL-6/blob/ma...ays.simba#L523

  4. #4
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by The Simba Noob View Post
    Knew it was in there somewhere, gave up after like 15 minutes.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •