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: joel:neely:fedex at: 22-Jun-2001 15:02

Hi, Jeff/nop Just a minor clarification... nop wrote:
> > random blockval > > > > is an abbreviation of > > > > foreach item blockval [append [] random item] > > > > which "distributes" RANDOM across the elements of the block > > and produces a block of results (by direct analogy with the > > result for tuple values) where each element is chosen at random > > within a range set by the corresponding element of the original > > block. > > No, because the above isn't guaranteed to be equally distributed > across the blocks contents. You could have duplicates. >
I wasn't saying that the above *is* the way RANDOM BLOCKVAL works, but rather that the above is the way one might have *expected* it to work, based on the facts that 1) The absence of /ONLY on APPEND etc. causes the APPENDing action to "distribute" across a second-argument block, and 2) The way RANDOM TUPLEVALUE works also "distributes" the RANDOM across individual elements (which does often create dups),
>> random 2.4.6.8 == 1.3.5.2 >> random 2.4.6.8 == 0.0.1.6 >> random 2.4.6.8 == 1.2.1.4 >> random 2.4.6.8 == 0.1.0.1
which I see as directly analogous to
>> map :random [2 4 6 8] == [1 2 5 1] >> map :random [2 4 6 8] == [2 3 2 7] >> map :random [2 4 6 8] == [1 4 5 6] >> map :random [2 4 6 8] == [2 2 6 4]
3) The fact that RANDOM TUPLEVALUE doesn't randomly reorder the elements of a tuple would have suggested that RANDOM BLOCKVALUE wouldn't randomly reorder the elements of a block (the other side of the coin from the previous point). I'm not trying to argue which specification for RANDOM BLOCKVALUE is correct (since the implementation is already done), but just to point out that there are *MANY* more options than two, therefore it takes more explanation than series as value vs. series as collection of values to clarify which of the possible options is implied by the presence or absence of /ONLY. It wasn't that I had never seen /ONLY before, but that all of my experience with it had led me to a different set of expectations. -jn- It's turtles all the way down! joel'dot'neely'at'fedex'dot'com