On Wed, Mar 3, 2010 at 11:39 AM, Graham Parkhouse
<[email protected]> wrote:
> T=: u/@:|.\S will do it, but will the interpreter recognize the quick way
> of doing u/@:|.\ (for any verb u)?
Wow, it took quite some time for me to parse this. I brought this up
recently in the other mailing list, and the answer is that the
interpreter already knows how to execute (u/\.) fast, which you can
use to make an equivalent of what you need. Let's see an example.
p =: '(',')',~[,'*',]
trace =: (3 :('1!:2&5''.''';'y'))@:
p trace/@:|.\ 'abcdefg'
.....................a
(b*a)
(c*(b*a))
(d*(c*(b*a)))
(e*(d*(c*(b*a))))
(f*(e*(d*(c*(b*a)))))
(g*(f*(e*(d*(c*(b*a))))))
p trace/\.&.|. 'abcdefg'
.......a
(b*a)
(c*(b*a))
(d*(c*(b*a)))
(e*(d*(c*(b*a))))
(f*(e*(d*(c*(b*a)))))
(g*(f*(e*(d*(c*(b*a))))))
You can see that the second phrase computes the same as the first, but
it calls the verb p fewer times.
Ambrus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm