>Given this verb:
>
> +/ 4 < 3 1 4 1 5 9
(A) That's a sentence, not a verb. The corresponding verb
would be +/@:< .
(B) Your version makes two passes; the J interpreter has no
lookahead, so it'll see the verb < first and execute
that, then it'll see the (derived) verb +/ and execute
that.
(C) Because of (B), to have any hope of optimization, the J
interpreter has to be able to "see" the phrase you want
optimized all at once. So it is possible for the verb
I gave in (A) to be optimized.
(D) Most of the cases optimized in the interpreter are
documented in Appendix B: "Special Code", available at:
http://www.jsoftware.com/help/dictionary/special.htm
(E) You can test to see if case is optimized with the performance
foreigns. Use:
ts =: 6!:2 , 7!:2@:] NB. Time & space required to execute a
sentence
x =: 4
y =: i. 1e7
100 ts '+/ x < y'
0.0464351 1.67782e7
100 ts 'x +/@:< y'
0.020715 1152
So, yes, +/@:< is optimized.
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm