If I understand the interpreter properly, it has a mechanism called
intrinsic rank, where the body of a verb is allowed to act at a higher
rank than what has been declared for the verb itself.
In other words, something like this:
IntrinsicRank=:2 :0
Z=. 0"n y
(Z ]"(-#$Z) u) y
:
Z=. x 0"n y
x (Z ]"(-#$Z) u) y
)
And, if V is a verb created by IntrinsicRank V b. 0 would return n
(which is why this would have to be implemented in the interpreter --
the above model is not sufficient).
This could either be a primitive (perhaps b:) or a foreign (perhaps
Ir=: 128!:6).
It seems to me that this could be a useful mechanism for J programmers.
First, with this mechanism you could recursively or inductively build
an array result and amortize the costs of this process over the entire
result rather than having to memoize or recompute intermediate results
for each cell.
For example:
fibonacci=:3 :0 b: 0
y{(,+/@{.~&_2)^:(>./,y) 0 1
)
Second, with this mechanism you could investigate (debug) mechanisms
which derive verbs which are sensitive to the rank of the component
verbs.
For example:
(i.2 3) +/ .(*&([smoutput)b:0) i.3 2
(And note that the above become legally valid statements if you
replace b: with " -- and the results of these example would be
identical. But the time taken by fibonacci will be significantly
higher and the session manager display from the smoutput example will
be different.)
Thoughs?
Thanks,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm