Pascal wrote:
"
'* %' eval
* %
"
Yes, one can write an explicit adverb (eval) to evaluate strings. One can
even write a fixed tacit adverb to evaluate strings; Dan’s anonymous evoke
(ae) is such an adverb but (even with some limitations) it is complicated
[0]. This was the motivation for implementing the adverb wl=. 104!:1 in
extended J. Thus,
'% *'eval
% *
'% *'ae
% *
'% *'wl
% *
So far everything is fine; but,
'v=: % *'eval
% *
v
% *
erase'v'
1
'v=: % *'ae
|domain error
| a:@.a:
'v=: % *'wl
v
% *
erase'v'
1
u v
u v
'u v'eval
|value error: v
| u v
'u v'ae
u v
'u v'wl
u v
'u=. * %'eval
* %
u
|value error: u
|[-0]
'u=. * %'ae
|domain error
| a:@.a:
'u=. * %'wl
u
* %
In other words, explicit definitions refer directly to arguments in a local
environment and an explicit (hybrid) writer has to worry about those issues.
Nevertheless, all this is beside the point that I was trying to make:
writing tacitly the common form of a conjunction taking two verbs directly
(as opposed to verb representations) is not possible (as far as I can see)
using the official J interpreter; not even for a simple conjunction that
produces a hook.
Pascal also wrote
"
'*' (; v2c ) '%' `:6
* %
'*' '%' (CONJ '; v2c') `:6
% *
'*' '%' (CONJs '; v2c') (`:6)
* %
"
Further, one can obviously write the adverb a0=. `:6 such that:
u`v a0
u v
Once an adverb is written in this common form it is straightforward to
write a related adverb (a1) that takes directly the two verbs in strand
form (abusing the concealed capabilities of evoke (`:6)):
u v a1
u v
How? Writing: a1=. ((<'`')`)(`(<@:(5!:1)@:<'a0')) (`:6)
Writing (u v a1) to get (u v) almost defeats its purpose but (u v) in (u v
a1) is not a train:
u (v a1)
u v
(v a1)
(`v)(`:6)
Now after all some puzzling sentences follow: :D
u v a0
u v
u (v a0)
u v
v a0
|value error: v
|[-13]
Finally, Pascal wrote:
"
]: is very interesting, though I'm still unsure that @: is a better
combiner than [:
"
Are you sure [: is a better combiner than @: ?
[0] Dan’s anonymous evoke
http://www.jsoftware.com/svn/DanBron/trunk/environment/anonymous_evoke2.ijs
On Wed, Aug 6, 2014 at 8:22 PM, 'Pascal Jasmin' via Programming <
[email protected]> wrote:
> thank you for sharing, Pepe
>
> your conj looks better for sure.
>
> thought, there is:
>
> '*' (; v2c ) '%' `:6
> * %
> '*' '%' (CONJ '; v2c') `:6
> % *
> '*' '%' (CONJs '; v2c') (`:6)
> * %
>
> '* %' eval
> * %
>
> where:
> CONJ =: 2 : ' u (v eval)'
> CONJs=: 2 : 'v eval u'
>
> these turn a conjunction into a "double adverb"
>
> ]: is very interesting, though I'm still unsure that @: is a better
> combiner than [:
>
>
>
>
> ----- Original Message -----
> From: Jose Mario Quintana <[email protected]>
> To: Programming forum <[email protected]>
> Cc:
> Sent: Wednesday, August 6, 2014 6:35:19 PM
> Subject: Re: [Jprogramming] parsing abuse, verb to conjunction
>
> Pascal wrote:
> "
> this adverb returns a conjunction which is designed to turn any dyadic verb
> into a conjunction
> "
>
> You might be interested to know that this is also what the adverb (conj)
> defined in [0] does; however, it is tacit, fixed and does not rely on
> linear representations which makes it immune to unwanted side effects and
> linear representations potential mishaps:
>
> NB. v2c...
>
> 5 (, v2c) 3 (2 1 , v2c) + 4
> 6 5 9 7
>
> 1 (4 :'x+y') 1
> 2
> 1 (4 :'x+y' v2c) 1
> 2
> 1 (4 :('assert. x>0';'x+y')) 1
> 2
> 1 (4 :('assert. x>0';'x+y') v2c) 1
> (1) (2 : 0) 1
> m 4 : 0
> assert. x>0
> x+y
> ) n
> )
>
> NB. conj...
>
> 5 (, conj) 3 (2 1 , conj) + 4
> 6 5 9 7
>
> 1 (4 :'x+y') 1
> 2
> 1 (4 :'x+y'conj) 1
> 2
> 1 (4 :('assert. x>0';'x+y')) 1
> 2
> 1 (4 :('assert. x>0';'x+y')conj) 1
> 2
>
> The primary objective for defining it (conj) was to produce, via wicked
> verbs, tacit conjunctions (which cannot be derived in the official version
> J). For example, hook can be defined tacitly as a conjunction as follows:
>
> hook=. train @: ; f.conj
> * hook %
> * %
>
> Unfortunately, v2c cannot be used for that purpose:
>
> hook=. train @: ; v2c
> * hook %
> |value error: n
> | m train@:; n
>
> In the latest version of the extended J interpreter, not yet released,
> conj, adv, verb and train can be defined as follows:
>
> an=. <@:((":0) ,&< ]) NB. Atomizing a noun (monadic verb)
> fix=. (?:(f.an)) NB. Cloaking the adverb f. as a (monadic)
> verb
> af=. an @: fix f. NB. Atomizing after fixing (monadic verb)
> ew=. adverb ?: (af'an') NB. Encasing a word (adv)
>
> ver=. ?: @: an f. NB. Cloaking an adverb or conjunction as a
> verb (verb)
> adv=. 1 ?: ((1 ?: an f.)ew) NB. Cloaking (the monadic variant of) a verb
> as an adverb (adv)
> conj=. (2 ?: an) f.adv NB. Cloaking (the dyadic variant of) a verb
> as a conjunction (adv)
> train=. (`:6)ver NB. Cloaking (`:6) as a verb
>
> Notice also that, in this latest version, ]: has been replaced by ?:.
> Why? Because ]: has been re-implemented to emulate the adverb At defined
> in [1]. Thus, for example, one can now write:
>
> [:u0 u1 u2 u3 u4]:
> u0@:u1@:u2@:u3@:u4
>
> [:<./+/|-/~]:
> <./@:(+/)@:|@:(-/~)
>
>
> [0] Tacit recursion without $:
>
> http://www.jsoftware.com/pipermail/programming/2014-February/035416.html
> [1] Tacit recursion without $:
> http://www.jsoftware.com/pipermail/programming/2014-March/035662.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