The whole purpose of ?. is to give repeated results. Every invocation
of ?. plays the same canned sequence of the underlying RNG.
?. 20 # 35
34 31 13 31 5 23 31 11 6 29 3 17 8 11 9 27 32 5 34 10
?. 20 # 7
6 3 6 3 5 2 3 4 6 1 3 3 1 4 2 6 4 5 6 3
Notice anything?
7 | ?. 20 # 35
6 3 6 3 5 2 3 4 6 1 3 3 1 4 2 6 4 5 6 3
If you want random numbers, use ? . If you want repeatability, use ?.
. If you want a bit of both, create a verb that cycles through a
million numbers dealt initially by ?. .
At this point there is so much test code that depends on the exact
behavior of ?. that we consider it untouchable.
Henry Rich
On 7/19/2020 8:33 AM, Hauke Rehr wrote:
I have an issue using ?. .
?. 2^y
gives the same result for several y in a row.
If I do
?. 2^y+i.x
for the same successive values,
the rng will iterate and values differ.
I understand the difference between the two
invocations and think it’s okay for them to
give different results; but I think it should
not be the case that the first way gives so
many repeated results.
Try
?. 2^y
for all y in 11+i.3 or 14+i.6 successively,
for example. They all give 1826 and 10018,
respectively. I think that’s bad.
In the documentation I did not find a statement
about these repetitions nor about the difference
between using ?. successively and using it on a list.
--
This email has been checked for viruses by AVG.
https://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm