Recurrent verbs have the capability of re-producing themselves or
variations of themselves. WARNING: they are powerful and one should try to
be careful when dealing with them to avoid falling into traps (just as one
should be careful, for example, when dealing with their cousins, the
recursive verbs) AND they are bending the interpreter to its limits; save
your work!
Pascal wrote: "Can body ever hope to execute an argument directly?"
Variations of body certainly can (see below).
Pascal wrote: "A generic (anonymous) way to create the "higgs-boson" state
of J :P ..."
Right, that is the reason why a few months ago I redefined the standard
library verb,
datatype
3 : 0
n=. 1 2 4 8 16 32 64 128 1024 2048 4096 8192 16384 32768 65536 131072 262144
t=. '/boolean/literal/integer/floating/complex/boxed/extended/rational'
t=. t,'/sparse boolean/sparse literal/sparse integer/sparse floating'
t=. t,'/sparse complex/sparse boxed/symbol/unicode/unicode4'
(n i. 3!:0 y) pick <;._1 t
)
as
". noun define -. CRLF
datatype=.
(<;._1 '|boolean|literal|integer|floating|complex|boxed|extended|r
ational|sparse boolean |sparse literal|sparse integer|sparse float
ing|sparse complex|sparse boxed |symbol |unicode|unicode4|?|?|verb
|adverb|conjunction') >@{~ 1 2 4 8 16 32 64 128 1024 2048 4096 819
2 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8
388608 i. 3!:0
)
Thus,
datatype GENOME
boxed
datatype@:> GENOME
verb
train=. (,^:(0:`(<'`:')))&6
(BW=. <@:train"0@:;:'+/"') NB. Boxing words (a verb, an adverb and a
conjunction)
┌─┬─┬─┐
│+│/│"│
└─┴─┴─┘
datatype&> BW NB. The datatypes of the words
verb
adverb
conjunction
I wrote: "This was the first recurrent verb I ever wrote; which was a proof
of concept (that a verb can seemingly take arguments as a strand)."
Is easy to write, with the aid of the Tacit Toolkit, a fairly general
recurrent verb sv that can seemigly provide strand notation, or convert
convert verbs to (seemingly) take arguments as a strand. Yet, starting
from scratch is not that difficult anyway:
Cloak=. (0:`)(,^:)
Cloak=. ((5!:1)@:<'Cloak')Cloak
'evoke fix amper'=. < o Cloak "0 o ;: '`: f. &'
train=. evoke&6 f.
an=. <@:((,'0') ,&< ])
z=. (((an'')`($ ,)`)(`:6))
indet=. (128!:5)z NB. Is Indeterminate?
eval=. ({. train o , an o ((train :: ])e) o }.)
body=. ([ amper > o {.) o ([ , <y)`(eval o }.x)@.(indet y)
GENOME=. < o fix'body' NB. GENOME=. body f.<adv
vs=. GENOME&body f.
One should begin at the beggining [0],
S=. vs ]`''
_66 [\ (5!:5)<'S'
((<([ ,^:(0:`&) >@:{.)@:([ , <@:])`(({. ,^:(0:``:)&6@:, <@:((,'0')
,&< ])@:(,^:(0:``:)&6 ::]&.>)@:}.)@:}.@:[)@.(('' ($ ,) 128!:5)@:]
)),<,<,']')&(([ ,^:(0:`&) >@:{.)@:([ , <@:])`(({. ,^:(0:``:)&6@:,
<@:((,'0') ,&< ])@:(,^:(0:``:)&6 ::]&.>)@:}.)@:}.@:[)@.(('' ($ ,)
128!:5)@:]))
S 'this' 'is' 'strand' 'notation' 0 a: (a.{~97+i.10) _.
┌────┬──┬──────┬────────┬─┬──┬──────────┐
│this│is│strand│notation│0│┌┐│abcdefghij│
│ │ │ │ │ ││││ │
│ │ │ │ │ │└┘│ │
└────┴──┴──────┴────────┴─┴──┴──────────┘
The arguments must be nouns, but if they are valid train (`:6) arguments
then their products are taken,
(BW=. S (<'+') (<'/') (<'"') (1 2 3) _.)
┌─┬─┬─┬─────┐
│+│/│"│1 2 3│
└─┴─┴─┴─────┘
datatype&> BW
verb
adverb
conjunction
integer
I will show other applications of vs another day.
Pascal wrote: "is there any way to use these noun arguments as part of a
tacit expression that will apply the functions to arguments?"
That might be a tricky question: Can you elaborate what you have in mind?
[0] [Jprogramming] Third argument (was: avoid boxing with fills - ?)
Dan Bron
http://www.jsoftware.com/pipermail/programming/2009-July/015541.html
On Tue, Mar 28, 2017 at 12:49 AM, 'Pascal Jasmin' via Programming <
[email protected]> wrote:
>
>
>
> Can body ever hope to execute an argument directly?
>
> A generic (anonymous) way to create the "higgs-boson" state of J :P
>
> fixB =: 1 : '<@:fix ''u'''
>
> +/ fixB
>
> 3!:0 every +/ fixB
> 2097152
>
> ???? - not on this page: http://www.jsoftware.com/help/
> dictionary/dx003.htm
>
>
> and then a sentence where body does not create a domain error:
>
> body
>
> +/ fixB body 2 3 NB. ignores y. but same result as monad, with +/ fixB
> as arg.
>
> (<+/)&(+/)
>
> can do stuff like
>
> +/ fixB , -/ fixB
> ┌──┬──┐
> │+/│-/│
> └──┴──┘
>
> is there any way to use these noun arguments as part of a tacit expression
> that will apply the functions to arguments?
>
> ________________________________
> From: Jose Mario Quintana <[email protected]>
> To: Programming forum <[email protected]>
> Sent: Monday, March 27, 2017 7:14 PM
> Subject: Re: [Jprogramming] introducing j plus plus
>
>
>
> Pascal wrote: "weird that I can't define the verb directly, though the echo
> can be eliminated"
>
> Yes, this is a weird wicked world :) The echo was there just to add
> suspense before the (faulty) linear representation of the verb was shown.
>
> In my mind, the simplest anonymous recurrent verb (so far) is (defined in
> slow motion),
>
> amper =. ,^:(0:`(<'&' ))
> fix =. ,^:(0:`(<'f.'))
> body =. [ amper >@:[
> GENOME=. <@:fix'body'
> me=. GENOME&body f.
>
> me (3) (2) (1)
> (<[ ,^:(0:`&) >@:[)&([ ,^:(0:`&) >@:[)
>
> This was the first recurrent verb I ever wrote; which was a proof of
> concept (that a verb can seemingly take arguments as a strand).
>
>
> Pascal wrote: " its hard to understand the verb to the left of &, as it
> seems to be a hook"
>
> "Seems" is the key word. It is not a hook, it is not even a verb, it is a
> noun! Likewise,
>
> type'GENOME'
> ┌────┐
> │noun│
> └────┘
> (5!:5)<'GENOME'
> <[ ,^:(0:`&) >@:[
>
> GENOME&body f.
> (<[ ,^:(0:`&) >@:[)&([ ,^:(0:`&) >@:[)
>
> GENOME
> ┌────────────────┐
> │[ ,^:(0:`&) >@:[│
> └────────────────┘
>
> Recall "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)"
>
>
>
>
> On Sun, Mar 26, 2017 at 10:34 PM, 'Pascal Jasmin' via Programming <
> [email protected]> wrote:
>
> > weird that I can't define the verb directly, though the echo can be
> > eliminated,
> >
> > WhoAmI=. (<@:(,^:(0:`(<'f.')))'body')&(body=. ([ (,^:(0:`(<'&'))) >)@:[
> [
> > ])f.
> >
> > creates a simpler version (missing lr quotes bug) that returns itself.
> >
> >
> > 1 WhoAmI 3
> > (<([ ,^:(0:`&) >)@:[ [ ])&(([ ,^:(0:`&) >)@:[ [ ])
> >
> >
> >
> > my version of Cloak (in jpp library btw)
> >
> >
> > eval =: 1 : 'if. 2 ~: 3!:0 m do. m else. a: 1 : m end.'
> > isNoun =: (0 = 4!:0 ::0:)@:<
> > aar =: 1 : 'if. isNoun ''u'' do. q =. m eval else. q =. u end. 5!:1 <
> > ''q'' '
> > Cloak =: (aar(0:`))(,^:)
> >
> > a =. ([ '&'Cloak >)
> >
> > I can't get this verb to do anything other than domain error,
> >
> > (< a@:[ [])&(a@:[ []) f. NB. doesn't quite produce the same verb, as
> > there's an extra paren.
> > (< (([ ,^:(0:`&) >)@:[ [ ]))&(([ ,^:(0:`&) >)@:[ [ ])
> >
> > even assigned, it also domain errors,
> >
> > but even in original, its hard to understand the verb to the left of &,
> as
> > it seems to be a hook where "<" would be smaller than. But just "a" is
> > hard to get too.
> >
> > ________________________________
> > From: Jose Mario Quintana <[email protected]>
> > To: Programming forum <[email protected]>
> > Sent: Sunday, March 26, 2017 1:28 PM
> > Subject: Re: [Jprogramming] introducing j plus plus
> >
> >
> >
> > 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-Februar
> > y/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
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm