[REBOL] Re: Question and comment about randomizing a block of values
From: joel:neely:fedex at: 18-Jun-2001 18:22
Hi, Volker,
[agem--crosswinds--net] wrote:
>
> usualy i shuffle like this:
> [rebol []
> n-cards: 20
> deck: copy []
> repeat i n-cards [append deck i]
> probe deck
>
> random/seed now
> shuffled-deck: copy []
> loop n-cards [
> card-no: random length? deck
> append shuffled-deck pick deck card-no
> remove at deck card-no
> ]
> probe shuffled-deck
> ]
>
It probably doesn't matter for small blocks, but I suspect the
overhead of plucking a value out of the middle of a block
(presuming that the following elements are scooted over to fill
the gap) might add up for larger blocks. That's one of the
reasons I proposed building a result without modifying the
original. Some benchmarking is probably in order to see whether
my suspicions are valid or total nonsense (both have been known
to happen ;-).
-jn-
___ ___ ___
\/ 2 + \/ 2 = 4 (for sufficiently large approximations of \/ 2 )
joel'dot'neely'at'fedex'dot'com