Yes... the limitation of 'trace' is that it only shows parsing, it (by
design) leaves execution alone.

I think this was one of the motivations for dissect.

That said, the fgh approach could also be extended to support &. if we
adopt a naming convention to identify inverses (or "obverses", but
here I think "inverse" has more mnemonic appeal). For example, let's
say that invf is the inverse of f. Then:

   f&.g/1 2
invg_((g_1)_f_(g_2))

Here's a reimplementation of fgh.ijs which does that:

bracket=: 3 :0
  if. 1=#y=.":y do. y else. '(',y,')' end.
)
instance=: 1 :0
 m,'_',bracket y
:
 (bracket x),'_',m,'_',bracket y
)
invinstance=: 1 :0
  if. 'inv'-: 3{. m do. (3}.m) instance else. ('inv',m) instance end.
)
instances=: 3 :0
  (y,'_z_')=:(y)=:y instance :.(y invinstance)
  ('inv',y,'_z_')=:('inv',y)=: y invinstance :.(y instance)
  EMPTY
)
linstances=: 3 :0
 instances y [ instances y,'l'
)
linstances"0 'fghi'

I hope this helps,

--
Raul


On Tue, Oct 25, 2022 at 2:59 PM Brian Schott <schott.br...@gmail.com> wrote:
>
> First of all, I agree with Raul's idea of an Essay approach and/or perhaps
> a Lab or a video. This conversation's applications and scripts are very
> complicated and valuable.
>
> I am really impressed with the power of fgh.ijs .
> For example the letters i,f,g and h are interchangeable placeholders and
> many powerful examples of trains and / and & modifiers are beautifully
> clarified showing the arguments in their positions in the results. The user
> needs to be told that the results use the _ character to show the valence
> of verbs, but that the verb pronouns must exclude the _ characters to
> actually work. (Although an example of the &. modifier is suggested in the
> fgh.ijs script, I got domain errors for it.)
>
> I am similarly impressed with tte which can be used with trains and  /  and
> & modifiers and in contrast to fgh.ijs tte employs primitive and named
> verbs.  But no actual arguments are involved in the output. Consider the
> following in 2 examples.
>
>    ( */ &. +) tte               NB. &. is not really demonstrated
> 3 : 0
> NB. */&.+
> ] t0=: */&.+ y NB. main: h-: '&.'
> :
> ] t0=: x */&.+ y NB. main: h-: '&.'
> )
>    ( */ & +) tte                NB. is there an error in dyad?
> 3 : 0
> NB. */&+
> ] u0=: */
> ] v0=: +
> ] r0=: <@v0 y
> ] q0=: u0@> r0 NB. atop: */&+
> :
> ] u0=: */
> ] v0=: +
> ] r0=: <@v0 x
> ] q0=: <@v0 y
> ] p0=: r0 u0@> q0 NB. compose: */&+  NB. is this an error?
> ] p0=: r0 u0&> q0 NB. compose: */&+  NB. does this correct?
> )
>
> dissect is mind blowingly versatile and especially helps with getting
> argument rank to coincide with verb ranks.
>
> 13|: and trace have been my goto debug devices, but the others mentioned
> above are really helpful, too. In exploring the ideas of this thread I was
> somewhat disillusioned by the following example of trace because it seems
> to reverse the order of Paren and Trident and hides the details of the
> Trident (fork) inside the processing of Dyad so there is not much help with
> trains.
>
>    trace '2(+ * -) 3'
>  --------------- 5 Trident ----
>  +
>  *
>  -
>  + * -
>  --------------- 8 Paren ------
>  (
>  + * -
>  )
>  + * -
>  --------------- 2 Dyad -------
>  2
>  + * -
>  3
>  _5
>  ==============================
> _5
>
> On Tue, Oct 25, 2022 at 10:54 AM Raul Miller <rauldmil...@gmail.com> wrote:
>
> > Actually, thinking about this, a series of related essays might be useful.
> >
> > I'm not quite sure how they should be labeled. But using J to build
> > expression-like results to illustrate concepts seems like a general
> > and illustrative technique for beginners. (Though of course it's also
> > useful for addons, like the math/calculus package.)
> >
> > Thanks,
> >
> > --
> > Raul
> >
> --
> (B=)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to