Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Question and comment about randomizing a block of values

From: hyakugei:theorganization at: 18-Jun-2001 22:26

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 - ----- Original Message ----- From: "Joel Neely" <[joel--neely--fedex--com]> To: <[rebol-list--rebol--com]> Sent: Monday, June 18, 2001 6:44 PM Subject: [REBOL] Re: Question and comment about randomizing a block of values
<snip> > > shuffled-iota: func [n [integer!] /local m f c r] [ > m: n * n > c: -1 > r: make block! n > loop n [append r (n * random m) + c: c + 1] > sort r > forall r [change r r/1 // n + 1] > head r > ] > > shuffled-block: func [b [block!] /local n i r] [ > r: make block! n: length? b > i: shuffled-iota n > foreach n i [append r pick b n] > ]
</snip> Wow. Thanks for 2 very interesting emails/articles on code refactoring! These are very clever methods, i'm going to have to go over them tonight, to try to figure out what is going on! (not that your explanation is not clear, i just need to 'actually do it' in rebol for it to sink in) <grin> I will do some speed comparisons too, tho the deck i will be using is pretty small (81 cards), so i might devise a larger 'test' deck to get better results... Thanks again for the well thought out code! jos "hyakugei" yule -----BEGIN PGP SIGNATURE----- Version: PGP 6.5.8 iQA/AwUBOy64Ud4WdA43RP/AEQKLNwCfRGU/K1ttz/GNnABN2Hq20O6ISyAAnROg C75Hg56PwDkZjHDgpcS19FDr =+QvR -----END PGP SIGNATURE-----