On Thu, May 1, 2014 at 12:30 PM, Joe Bogner <[email protected]> wrote: > I built a small helper to log verb execution. I'll write up a wiki post on > it once my wiki password gets reset > > I am not sure if it will help others, but it was fun to build. > > Let's start by comparing to the built-in trace: > > require'trace' > > trace '(+/ % #) (5 10 15)' > > --------------- 8 Paren ------ >
I would like to take this opportunity to provide a friendly reminder that in Chrome you should always use "paste as plain text" to paste from a J session into the browser. (This is Ctrl+Shift+V on windows and probably Cmd+Shift+V on mac and perhaps also in Safari.) > --------------- 0 Monad ------ > +/ % # > 5 10 15 > 10 > ============================== > 10 > > I can see my fork is working correctly but I found the output very > confusing when I started with J and still don't quite follow it all the > time. I would have thought that the last operation was dyadic too... That last monad is the verb (+/ %#) as a whole. You are probably thinking of the division which happens inside. Actually, you probably already know this because the topic of your post is tracing execution inside verbs and you have a working implementation for that. This trace provides detail of what happens "inside" the execution of the compound verb you have constructed here. (It happens after the parsing has completed.) > Executing from right to left, we see that first J evaluates # on our list, > then +/ on the same list, and then executes % dyadically on the results of > both And, just to reinforce the point: execution happens after parsing has completed. What you are describing happens "inside" the verb, when it has data to chew on. Parsing is the process of constructing the verb. mean=: +/ % # mean 1 2 3 2 mean 2 3 5 3.33333 If you traced the execution of 'mean=: +/ % #' that final monad step would be missing from your trace. And, if you traced the execution of 'mean 2 3 5' you would then see that final monad step. Parsing and execution can be thought of as distinct operations. They are not entirely distinct, but sometimes it helps to think of them that way. This can be especially illuminating when understanding and talking about other programming languages. Often it's just easier to focus on practical uses rather than the details of just how simple this actually is. Thanks, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
