See also "trace" in the system library. e.g.
load 'trace'
trace 'sum=: +/'
--------------- 3 Adverb -----
+
/
+/
--------------- 7 Is ---------
sum
=:
+/
+/
==============================
trace 'sum"1 ]2*i.3 5'
--------------- 1 Monad ------
i.
3 5
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
--------------- 2 Dyad -------
2
*
i.3 5
0 2 4 6 8
10 12 14 16 18
20 22 24 26 28
--------------- 4 Conj -------
sum
"
1
sum"1
--------------- 1 Monad ------
]
2*i.3 5
0 2 4 6 8
10 12 14 16 18
20 22 24 26 28
--------------- 0 Monad ------
sum"1
2*i.3 5
------------------------------
+/
0 2 4 6 8
20
==============================
+/
10 12 14 16 18
70
==============================
+/
20 22 24 26 28
120
==============================
20 70 120
==============================
20 70 120
----- Original Message -----
From: Don Guinn <[EMAIL PROTECTED]>
Date: Wednesday, January 3, 2007 2:18 pm
Subject: Re: [Jprogramming] Re: easy way of capturing output from 0!:0
> Sounds like you want a way to trace the execution of a verb. I
> have
> wanted something like that ever since I first played with J and
> looked
> in J for something like the []TRACE that was in STSC APL but
> couldn't
> find it.
>
> Got to playing with it and came up with this:
>
> vtrace=: 1 : 0
> NB. c=.<'((1!:2)&2)'
> c=.<'(((1!:2)&2)20#''_'')]((1!:2)&2)'
> y
> t=.u f.
> 'f t'=.(<@{.,<@}.)<;._1]LF,5!:5<'t'
> f=.<'z=.(',(>f),') y'
> 0!:100] ;((0,-.t e.;:':)')#&.>c),.(f,t),.<LF
> z
> :
> NB. c=.<'((1!:2)&2)'
> c=.<'(((1!:2)&2)20#''_'')]((1!:2)&2)'
> x
> y
> t=.u f.
> 'f t'=.(<@{.,<@}.)<;._1]LF,5!:5<'t'
> f=.<'z=.x (',(>f),') y'
> 0!:100] ;((0,-.t e.;:':)')#&.>c),.(f,t),.<LF
> z
> )
>
> p=: 3 : 0
> 'Monadic'
> +y
> :
> 'Dyadic'
> x+y
> )
>
> p vtrace 3j4
> ____________________
> Monadic
> ____________________
> 3j_4
> 3j_4
> 7+1 p vtrace 3j4
> ____________________
> Dyadic
> ____________________
> 4j4
> 11j4
>
> t trace 1
> ____________________
> 0 1 2 3 4 5 6 7 8 9
> ____________________
> 45
> ____________________
> 450
> 450
>
> "vtrace" stands for "verb trace" as the name "trace" is already
> defined
> and "vtrace" will only trace verbs. It works a little differently
> than
> what you asked for as it does return a value, the result of the
> verb,
> and I put in a separator between the displayed output so it is
> easier to
> see where each statement's output begins. And it's an adverb so it
> takes
> the verb to trace as a left argument. And you need to supply "y"
> and "x"
> to get it to do anything.
>
> Notice "c" in "vtrace". Replace it with whatever you want to do
> with the
> output. Send it to a file if you want. If you have a verb in the
> middle
> of a statement you want to trace, simply stick "vtrace" just after
> it
> and the statement should still execute as before, except now each
> statement will be listed as defined in "c".
>
> I don't know what to do for tracing adverbs and conjunctions.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm