On Wed, Feb 23, 2011 at 9:04 PM, Brian Schott <[email protected]> wrote:
> Update:
>
>        I suspect my problem is that my verbs are recursive
> such as `foo=: 10&$: : *` and trace has not dealt with this.

You can make recursive verbs traceable by building trace into the
verbs.

For example, here is recursive factorial:
  (*$:@:<:)^:(1&<)

And, if you fix trace, here is a traced version

factorial=: 3 :'trace ''(*factorial_base_@:<:)^:(1&<)'',linrep y'

Here is the fix needed:

require'trace'
linrep_z_=: 3 :0
  5!:5<'y'
)

trace_jtrace_=:3 : 0
 _ trace y
:
 tracer=. conew 'jtrace'
 r=.". >(<1 1){parse__tracer 'trace';x;y
 coerase tracer
 r
)

Note that a recursive function cannot, in general, know what locale it
is being called from, and trace does not make any provisions for
specifying a local to use for names, so the recursive factorial needs
to explicitly reference its home locale.

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to