I wrote:
> Roger, what is the rationale for not changing the advertised
> rank of ?.
Well, I suppose one reason is that if you do, verbs derived from ?. would
differ syntactically (not just semantically) from
their analogs which use ? .
For example, with the current, rank-0 fixed-seed:
<@?. 3 4 5
+-+-+-+
|0|2|1|
+-+-+-+
<@? 3 4 5
+-+-+-+
|2|2|0|
+-+-+-+
But with my proposed rank-_ fixed-seed:
<@(?."_) 3 4 5
+-----+
|0 3 4|
+-----+
Which makes ?. a lot less like ? (which defeats the purpose of having
it).
An alternative to redefining fixed-seed is to decomission it. Replace it with
a library function which sets the RNG and seed to
some known, predefined, value. Call this function rrs . Then, examples
currently employing ?. would be changed to use ?
but call rrs first.
This has the advantage that such examples would be identical to their "real
life" counterparts, except some production flag would
inhibit the invocation of rrs . The disadvantage is that such examples would
not be possible in "pure J", as the entire
development system would be required for the defintion of rrs to be
available.
To ameliorate that disadvantage, perhaps a new foreign could be assigned, which
resets the RNG and seed to their default values.
Summary: I propose an alternative to the current, problematic, definition of
?. . That verb could be decomissioned, and a new
foreign be assigned, which would reset the RNG and seed to their default values.
-Dan
PS: The verb rrs could be defined thus:
rrs =: verb define NB. Reset random seed
(9!:43) 2
(9!: 1) 16807 NB. 7^5
i.0 0
)
Example:
? 10
0
? 10
7
? 10
8
rrs ''
? 10
0
? 10
7
? 10
8
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm