Hello list,

As I understand, in J you have to write tacitly to make things be fast (is
this right?).
Sometimes I would like to store and to extract intermediate results from
inside of a tacit verb, when processing large array. I believe, this may
considerably reduce complexity and execution penalty of a verb.
Unfortunately, I don't see an effective way to do this.
The idea is something like this:

   setA =: 13 : 'A=:y'"0
   6!:2 'setA i. 1000000'
5.63823
   setA
+----------+-+-+
|+-+-+----+|"|0|
||3|:|A=:y|| | |
|+-+-+----+| | |
+----------+-+-+
^^^No, way...
There is no tacit representation for this. Also performance is not good due
to the parsing inside of a loop, I guess. The name lookup and the update
itself probably don't consume a lot, if compared to this:

   nop =: 3 : '+y'"0
   nop
+--------+-+-+
|+-+-+--+|"|0|
||3|:|+y|| | |
|+-+-+--+| | |
+--------+-+-+
   6!:2 'nop i. 1000000'
5.05352

Of course, the tacit equivalent of noop is much faster:

   6!:2 '+"0 i. 1000000'
0.011353

So, how would you deal with this? Should one really always stretch his brain
for the pure tacit solutions without use of 'temp variables'?

regards,
   Danil
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to