Fraser:
Here's the problem.
The sentence
2 t1 1;2
is going to invoke sel^:(1 2) 1;2. This is equivalent to
(sel^:1 (1;2)), (sel^:2 (1;2))
In any case, sel is going to be invoked 3 times (not twice, as you seem to
expect). From the dictionary:
Finally, u^:n y for an array n is produced by assembling u^:a y (for all
the atoms a in n) into an overall result.
If there are no side effects, it might be reasonable for J to only do two
evaluations in sel^:(1 2) 1;2. Since there are side effects, I cannot see
a consistent interpretation that results in only two evaluations.
If I understand what you want, you are probably better off rewriting it so
that you invoke it as
INFO_base_=: f^:<(>:n) init
Here f is effectively ],(sel@:{:), so it applies sel to the last row of
its argument, and appends the result to its argument. You can also
rewrite this in other ways. Since f is now a pure function, you don't
care how J calculates it.
Best wishes,
John
Fraser Jackson wrote:
> Thanks Henry, Raul and John for the helpful comments. The following
> script
> reproduces the problem. It seems to only occur when the verb has a boxed
> argument. The box characters below may not reproduce correctly.
>
> t1 =: 4 : 0
> INFO_base_ =: 0 2$0
> sel^: (>:i.x) y.
> )
>
> sel =: 3 : 0
> 'r s' =. y.
> v =. (>:r), 1.1*s
> INFO_base_ =: INFO_base_ , v
> <"0 v
> )
>
> 2 t1 1;2
> ????????
> ?2 ?2.2 ?
> ????????
> ?3?2.42?
> ????????
> INFO_base_
> 2 2.2
> 2 2.2
> 3 2.42
>
> Taking the Dictionary sentences refering to scalar n and to array n, one
> would expect the verb to be evaluated exactly n times for both n and ,n.
> Whether the data is a boxed array or not should not modify that
> expectation.
>
> Fraser
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm