[REBOL] Re: Question and comment about randomizing a block of values
From: joel:neely:fedex at: 22-Jun-2001 15:02
Just a minor clarification...
> > 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 126.96.36.199 == 188.8.131.52
>> random 184.108.40.206 == 0.0.1.6
>> random 220.127.116.11 == 18.104.22.168
>> random 22.214.171.124 == 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.
It's turtles all the way down!