Dissect, the 2-D sentence debugger, now supports all J primitives, in
most of their forms (it doesn't handle gerunds on partitioning modifiers
or }). It is an addon and is described at
http://www.jsoftware.com/jwiki/Vocabulary/Dissect
Dissect is especially useful if you are teaching J. Suppose a student
reads that +//.@(*/) does polynomial multiplication. How much fun is it
going to be to explain THAT? Just let em run
dissect '4 1 2 3 +//.@(*/) _1 4 0 2 6'
and they can happily click on individual numbers and see where they came
from.
Even if you're an expert you will want to use dissect if you have a
complicated sentence that is failing. For example:
]a =. (<0 1);<(<2 3 4);(1);<<5 6;7 8
+-----+-----------------------+
|+---+|+-------+-+-----------+|
||0 1|||+-----+|1|+---------+||
|+---+|||2 3 4|| ||+---+---+|||
| ||+-----+| |||5 6|7 8||||
| || | ||+---+---+|||
| || | |+---------+||
| |+-------+-+-----------+|
+-----+-----------------------+
a: ,L:1 a
|domain error
| a: ,L:1 a
You might not be one of the very few people, if indeed there are any,
who can see right off why this sentence failed. But if you run
dissect 'a: ,L:1 a'
or just use a PFkey set up to dissect the last line that failed, you
will immediately see the source of the problem. (The Wiki shows how to
set up a PFkey).
How about debugging recursions? Bring back some painful memories?
Looking at an error message like
'b c' =. 'a';5
>:`($:&.>)@.(0<L.) 1 2 3;<4 5;<<b;c
|domain error
| >:`($:&.>)@.(0<L.)1 2 3;<4 5;<<b;c
?
Run
dissect '>:`($:&.>)@.(0<L.) 1 2 3;<4 5;<<b;c'
and you'll see the results of all the recursions, with the failing one
exposed in detail; you can look through them one at a time if you like.
For fun, you can see quicksort (as described in the J Wiki) all at once with
a =. 20 ? 50
dissect '(($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#) a'
Henry Rich
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm