On 2020-07-19 16:10, Julian Fondren wrote:
On 2020-07-19 16:08, David Lambert wrote:
At the end of this sentence I had hoped the global variable A would
have
more items.
A =: A , >:@:([ 3 :'echo A =: A , y')^:4 [ A =: , 0
0 0
0 0 1
0 0 1 2
0 0 1 2 3
A NB. The intermediate values we need are gone!
0 4
A , >:@:([ 3 :'echo A =: A , y')^:4 [ A =: , 0
0 0
0 0 1
0 0 1 2
0 0 1 2 3
0 4
A
0 0 1 2 3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More usefully:
A , ] >:@:([ 3 :'echo A =: A , y')^:4 [ A =: , 0
0 0
0 0 1
0 0 1 2
0 0 1 2 3
0 0 1 2 3 4
I guess the question is: what's the rule for when A gets its
value in the sentence? Without that added ], the leftmost A has
the value it's given by the A=:,0 on the right. With the ]
there, A's value isn't considered until after more of the
evaluation of the sentence.
My hint in adding the ] is that
- the obvious solution is to have separate sentences so that
A values are unambiguous
- J uses ] [ for that instead of APL's ⋄
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm