Debugging with an adverb
Often enough I need to debug my own code. The following adverb can be attached to any verb to trace its argument(s) and result:t =: 1 : 0 smoutput 'y:' smoutput y z =. u y smoutput 'result:' smoutput z z : smoutput 'x:' smoutput x smoutput 'y:' smoutput y z =. x u y smoutput 'result:' smoutput z z )You can attach this t adverb to the right of any verb in your epression to have it traced:2 * 6 +t&*: 9 x: 36 y: 81 result: 117 234A more compact form of the adverb is thinkable, too:t2 =: 1 : 0 smoutput y ; z=. u y z : smoutput x ; y ; z=. x u y z ) -t2/ 1 2 3 4 +-+-+--+ |3|4|_1| +-+-+--+ +-+--+-+ |2|_1|3| +-+--+-+ +-+-+--+ |1|3|_2| +-+-+--+ _2While former "t" implementation may look more clumsely, it will still show you the arguments when the verb itself will fail -- often a helpful piece of information. The second one won't provide this.
(Up to and including J Rel. 4.x, the trace adverb can be affixed to not just conjunctions and adverbs, too. You will get the derived function's arguments and results traced. I.e., 6 +&t*: 9 works and show the 6 9 and 117. With later releases, this only holds for adverbs.)