All the work that Pascal has done for jpp is appreciated.
What would be nice now would be some user documentation
with examples. I did look at the readme file, but could not
understand it well enough to get any further.

There is another approach possible to the project of a
j preprocessor. There is an excellent macro processor,
gema ( http://gema.sourceforge.net/new/index.shtml  )

Here is a session transcript demonstrating how it could be used with J.

  (1!: 44) jpath '~temp'     NB. all the files are set up in temp


   NB. suppose we aim to write monadic oneliner verbs in the form
   NB.
   NB.      foo z =: expr
   NB.
   NB. allowing free choice of argument name without the need for quotes.
   NB.
   NB. the macro-expansion is to be:
   NB.
   NB.      foo =: 3 : ('z=.y'; 'expr')
   NB.

   NB. step 1 is to create a file with the necessary macro defn.

   (0 : 0)(1!:2) < 'macrodefs.txt'
<A> <A> \=\:\  <P> = $1 \=\: 3 \:  (\'$2\=\.y\'\; \'$3 \') \N
)

   NB. step 2 is to define a load verb which calls the macro-processor

   mload =: 3 : 0
  require 'task'
  assert. fexist y
  assert. fexist 'gema.exe'
  assert. fexist 'macrodefs.txt'
  _1 fork_jtask_ 'gema -f macrodefs.txt ',y , ' temp.ijs'
  load 'temp.ijs'
)

   NB.  step 3 is to create  a demo script with new-syntax verbs

   (0 : 0)(1!:2) < 'script.ijs'

foo z =: z + 1
bar w =: (+/ % #) w
)


   NB.  step 4 is to load the script, expanding the macros

   mload 'script.ijs'

   NB.  step 5 is to show the results

   foo
3 : 0
z=.y
z + 1
)

   foo 3
4

   bar
3 : 0
w=.y
(+/ % #) w
)

   bar 2 3 4
3


Regards,

  Roger

On Sun, Mar 26, 2017 at 6:28 PM, Jose Mario Quintana <
[email protected]> wrote:

> Before I show how the verb  WhoAmI  can be produced it might helpful to
> explain how it works.  The verb echoes its right argument (''), discards it
> and anonymously reproduces, an exact copy of, itself; then, the reproduced
> verb echoes its right argument ('I am presenting myself by executing this
> sentence :)') discards it and anonymously reproduces an exact copy of
> itself, and so on until there are no more arguments and the reproduced verb
> shows up.
>
> The verb, with the aid of the Tacit Toolkit mentioned often in the
> Adverbial Tacit Jym thread, can be written easily as a one-liner,
>
>    WhoAmI=. (body f.<adv)&(body=. ([ amper >)x [ echo y)f.
>
> It uses the typical ancient trick that self-reproducing beings employ
> (e.g., living beings): The whole being (WhoAmI) consists of a description
> of the body (body f.<adv) bonded (&) to the body f.  A variation of this
> verb provides the means for producing general verbs that seemingly take
> directly arguments as a strand (more on that later in a new thread).
>
> A self-contained version of  WhoAmI  can also be written as a
> slightly longer one-liner (beware of line wrapping),
>
>    WhoAmI=. (<@:(,^:(0:`(<'f.')))'body')&(body=. ([ (,^:(0:`(<'&'))) >)@:[
> [ echo @:])f.
>
> Incidentally, the display of the following sentence is slightly different
> from the output in my original post (it includes extra blank lines
> corresponding to the empty literals ('').   It seems that JQT and JHS are
> NOT behaving exactly in the same way.  I am running here Win JQt05 whereas
> I produced the original output with Safari on an iPad as a client of a
> custom JHS on a Kindle Paperwhite server but I just confirmed that Win
> JHS05 with MS Edge produces the same output (without extra blank lines).
>
>    WhoAmI '' 'I am presenting myself by executing this sentence :)' ''
> 'Spoiler coming in,' '' (,.|.i.33) '' (|.'...brev gnicudorper-fles eht ma
> I') ''
>
> I am presenting myself by executing this sentence :)
>
> Spoiler coming in,
>
> 32
> 31
> 30
> 29
> 28
> 27
> 26
> 25
> 24
> 23
> 22
> 21
> 20
> 19
> 18
> 17
> 16
> 15
> 14
> 13
> 12
> 11
> 10
>  9
>  8
>  7
>  6
>  5
>  4
>  3
>  2
>  1
>  0
>
> I am the self-reproducing verb...
>
> (<([ ,^:(0:`&) >)@:[ [ 0 0&$@(1!:2&2)@:])&(([ ,^:(0:`&) >)@:[ [ 0
> 0&$@(1!:2&2)@:])
>
>
> On Thu, Mar 23, 2017 at 11:26 AM, Jose Mario Quintana <
> [email protected]> wrote:
>
> > Sure, the little puzzle, even after the spoiler, is not that easy :) ...
> > Notice the smiley at the end of
> > 'I am presenting myself by executing this sentence :)'
> >
> > There is no way the poor old untrusty linear representation (LR)  ;)  can
> > faithfully represent  WhoAmI  for two reasons (another spoiler follows
> > after a few blank lines):
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > First, the Superbug is pestering the LR of certain embedded gerunds, for
> > example,
> >
> >    ^:(0:`(<'&'))
> > ^:(0:`&)
> >
> > Last, but certainly not least, the LR is trying its best to deal with a
> > noun that, arguably, should not be part of J's reality but fortunately it
> > is.  That is, a box containing a verb (in my mind this is the simplest
> way
> > for a noun to represent a verb , adverb or conjunction; to recover the
> word
> > just open the box); for example, if  V  is a box containing the verb  *
> >  then,
> >
> >    V
> > ┌─┐
> > │*│
> > └─┘
> >    (5!:5)<'V'
> > <*
> >
> > Later I will show how I produced the recurrent verb  WhoAmI  which is,
> > giving the illusion of, taking arguments as a strand.
> >
> >
> >
> >
> >
> > On Thu, Mar 23, 2017 at 12:15 AM, 'Pascal Jasmin' via Programming <
> > [email protected]> wrote:
> >
> >> get syntax error
> >>
> >>
> >>
> >>
> >> ________________________________
> >> From: Jose Mario Quintana <[email protected]>
> >> To: "[email protected]" <[email protected]>
> >> Sent: Wednesday, March 22, 2017 11:44 PM
> >> Subject: Re: [Jprogramming] introducing j plus plus
> >>
> >>
> >>
> >> Thanks for the feedback Pascal.  I just realized that I might have used
> >> tacit anonymous continuations inadverterdly when I wrote, in Jx, the
> tacit
> >> recurrent (aka multiple) adverbs   sa   and   sna  which can convert
> >> adverbs taking arguments as a gerund into adverbs taking arguments  as a
> >> strand [0].  Incidentally, I have rewriten similar versions of
> >> adverbs which run in official J interpreters but that should be a
> subject
> >> for another thread in another time.
> >>
> >> In the meantime the following is a little puzzle in the same vain:
> >>
> >>
> >> WhoAmI '' 'I am presenting myself by executing this sentence :)' ''
> >> 'Spoiler coming in,' '' (,.|.i.33) '' (|.'...brev gnicudorper-fles eht
> >> ma I') ''
> >> I am presenting myself by executing this sentence :)
> >> Spoiler coming in,
> >> 32
> >> 31
> >> 30
> >> 29
> >> 28
> >> 27
> >> 26
> >> 25
> >> 24
> >> 23
> >> 22
> >> 21
> >> 20
> >> 19
> >> 18
> >> 17
> >> 16
> >> 15
> >> 14
> >> 13
> >> 12
> >> 11
> >> 10
> >> 9
> >> 8
> >> 7
> >> 6
> >> 5
> >> 4
> >> 3
> >> 2
> >> 1
> >> 0
> >> I am the self-reproducing verb...
> >> (<([ ,^:(0:`&) >)@:[ [ 0 0&$@(1!:2&2)@:])&(([ ,^:(0:`&) >)@:[ [ 0
> >> 0&$@(1!:2&2)@:])
> >>
> >>
> >> [0] [Jprogramming] Tacit recursion without $:
> >>
> >> *
> >> http://www.jsoftware.com/pipermail/programming/2014-
> February/035416.html
> >> <http://www.jsoftware.com/pipermail/programming/2014-
> February/035416.html
> >> >*
> >>
> >>
> >>
> >
> ----------------------------------------------------------------------
> 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