Here’s a solution in simple J.  The original request was for a tacit solution:

 

    ]A=: (+:`*:;i.5)

┌───────┬─────────┐
│┌──┬──┐│0 1 2 3 4│
││+:│*:││         │
│└──┴──┘│         │
└───────┴─────────┘

   f=: 13 :'".(>0{>0{y),":i.$>1{y'

   f A

0 2 4 6 8

   

Linda

 

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of 'Pascal Jasmin' 
via Programming
Sent: Monday, February 2, 2015 1:23 AM
To: [email protected]
Subject: Re: [Jprogramming] conjunction in tacit verb

 

a 3rd tacit (and some "almost tacit") version

 

anV =: <@:((,'0') ,&< ])  NB. your an

an =: 1 : '<@:((,''0'') ,&< ]) m'  NB. as adverb

w =: @.0 2   NB. result of 0 2 agenda

c2da =: 1 : ( 'a =. (m ,'' u'') label_. 1 : (''u  1 :'' , quote a)') tie =. 
'`'c2da

 

JVERSION

Engine: j701/2011-01-10/11:25

Library: 8.02.07

Qt IDE: 1.1.2/5.3.0

Platform: Win 64 

 

 

1000 st every '+:*:(anV i.5) tie tie 0 2 agenda';'u +:`*:;i.5';'(+:`*: , ( anV 
i.5) ) w';'(+:`*: , (i.5) an) w'

 

┌────────────────────────────────┬─────┬──────────┬─────────┐

│+:*:(anV i.5) tie tie 0 2 agenda│13696│3.08835e_5│0.422981 │ 
├────────────────────────────────┼─────┼──────────┼─────────┤ 

│u +:`*:;i.5                     │6656 │1.64672e_5│0.109606 │ 

├────────────────────────────────┼─────┼──────────┼─────────┤ 

│(+:`*: , ( anV i.5) ) w         │4608 │4.70272e_6│0.0216701│ 

├────────────────────────────────┼─────┼──────────┼─────────┤ 

│(+:`*: , (i.5) an) w            │5888 │7.76736e_6│0.0457342│ 

└────────────────────────────────┴─────┴──────────┴─────────┘

 

 

 

________________________________

From: Jose Mario Quintana < <mailto:[email protected]> 
[email protected]>

To: Programming forum < <mailto:[email protected]> 
[email protected]>

Sent: Sunday, February 1, 2015 11:16 PM

Subject: Re: [Jprogramming] conjunction in tacit verb

 

 

So far two main tacit solutions have been shown.  The first, bending the

rules,

 

   an=. <@:((,'0') ,&< ])

   Cloak=. ((5!:1)@:<'Cloak')Cloak=. (0:`)(,^:)

   train=. (Cloak <'`:')&6  NB. `:6 verbalized

 

   ( v=.  <mailto:train@:(%7b.@:(0&(%7b::))> train@:({.@:(0&({::)) ; an@:>@:{:) 
f. )

,^:(0:``:) <mailto:&6@:(%7b.@:(0&(%7b::))> &6@:({.@:(0&({::)) ; <@:((,'0') ,&< 
])@:>@:{:)

 

The second, following the rules,

 

   fe=: 13 : 0

'0:';<'@:';<((0;0){::y);<(,'"');<((,'0');1{::y);<((,'0');_)

)

 

   ( u=. ]^:] fe f. )

]^:] ('0:' ; [: < '@:' ; [: < ((0;0) {:: ]) ; [: < (,'"') ; [: <

(<(,'0');_) ;~ (,'0') ; 1 {:: ])

 

Let us compare them,

 

   Y=. +:`*:;i.5

 

   (u -: v) Y

1

 

   sp=. 7!:5@:<

   sp&> ;:'u v'

2432 1920

 

   st=. (, */&.:>@:(1 2&{))@:(] ; 7!:2@:] ; 6!:2)

   10000 st&> 'u Y' ; 'v Y'

┌───┬────┬──────────┬──────────┐

│u Y│2624│1.49229e_5│0.0391576 │

├───┼────┼──────────┼──────────┤

│v Y│1920│4.96943e_6│0.00954131│

└───┴────┴──────────┴──────────┘

 

By the way, Patriots 28 Seahawks 24, a fine example that bending the rules

pays off ;)

 

 

 

 

 

On Sun, Feb 1, 2015 at 4:07 PM, Jose Mario Quintana <

 <mailto:[email protected]> [email protected]> wrote:

 

> "Or, you can use ]^:]"

> 

> Sneaky?  (See,

>  <http://www.jsoftware.com/pipermail/programming/2013-January/031234.html> 
> http://www.jsoftware.com/pipermail/programming/2013-January/031234.html

> and

>  <http://www.jsoftware.com/pipermail/programming/2013-January/031236.html> 
> http://www.jsoftware.com/pipermail/programming/2013-January/031236.html

> )

> 

> "

> But maybe it's also easy enough to use J's parser and not bother with

> tacit for this kind of exercise?

> "

> 

> Maybe, but the question that started this thread was,

> "Is it possible to define f tacitly?"

> 

> 

> 

> On Sun, Feb 1, 2015 at 3:38 PM, Raul Miller < <mailto:[email protected]> 
> [email protected]> wrote:

> 

>> Or, you can use ]^:]

>> 

>> It's not really that hard.

>> 

>>  <http://www.jsoftware.com/help/dictionary/d202n.htm> 
>> http://www.jsoftware.com/help/dictionary/d202n.htm says:

>> 

>>   u^:(   v1`v2)y ↔ u^:(v1 y) (v2 y)

>> 

>> So let's make v1 be 0: and v2 be a data structure which represents our

>> entire calculation:

>> 

>>    ]^:] 0:`(+:@:(0 1 2 3 4"_))

>> 0 2 4 6 8

>> 

>> Now all we need is a verb which transforms

>>    (+:`*:;i.5)

>> to

>>    0:`(+:@:(0 1 2 3 4"_))

>> 

>> It's straightfoward to do this explicitly.

>> 

>> Let's define a test:

>> 

>> ex=: +:`*:;i.5

>> assert 0:`(+:@:(0 1 2 3 4"_)) -: fe ex

>> 

>> Now we just need to define fe so that the above script does not throw

>> an error. So take a look at what 0:`(+:@:(0 1 2 3 4"_)) looks like and

>> transcribe that to code:

>> 

>> fe=:3 :0

>>  '0:';<'@:';<((0;0){::y);<(,'"');<((,'0');1{::y);<((,'0');_)

>> )

>> 

>> Testing:

>> 

>>    ]^:] fe ex

>> 0 2 4 6 8

>> 

>> Now.. that expression for fe is messy, and a little tedious to write,

>> but if you don't mind a little bit of trial and error and

>> investigation while you work through whatever uncertainties you have

>> about what you are seeing, you can do it.

>> 

>> And converting it to tacit can be done like this:

>> 

>> fe=:13 :0

>>  '0:';<'@:';<((0;0){::y);<(,'"');<((,'0');1{::y);<((,'0');_)

>> )

>> 

>> (And then look at the definition of fe using linear representation.)

>> 

>> Oh, but that's cheating!

>> 

>> Um... why?

>> 

>> It's not, not really. You learn from whatever interests you.

>> 

>> That said, it *can* be an interesting exercise to construct sensibly

>> named concepts for building that kind of data structure.

>> 

>> But maybe it's also easy enough to use J's parser and not bother with

>> tacit for this kind of exercise?

>> 

>> Thanks,

>> 

>> --

>> Raul

>> 

>> 

>> On Sun, Feb 1, 2015 at 3:09 PM, Jose Mario Quintana

>> < <mailto:[email protected]> [email protected]> 
>> wrote:

>> > "

>> > The agenda trick doesn't quite solve the problem though due to train

>> > formation rules:

>> > "

>> >

>> > Actually, when evaluating atomic representations, gerunds, etc. whatever

>> > one can accomplish using train (`:6) one can accomplish it using agenda

>> > (@.) as well (and vice versa).

>> >

>> >    JVERSION

>> > Installer: j602a_win.exe

>> > Engine: j701/2011-01-10/11:25

>> > Library: 6.02.023

>> >

>> >    ( agenda=. Cloak <'@.' )  NB. @. verbalized

>> > ,^:(0:`@.)

>> >

>> >    u=. agenda&0  <mailto:1@:(%7b.@:(0&(%7b::))> 1@:({.@:(0&({::)) ; 
>> > an@:>@:{:) f.

>> >    u (+:`*:;i.5)

>> > 0 2 4 6 8

>> >

>> > Alternatively,

>> >

>> >    caravan=. agenda&0@:<

>> >

>> >    u=.  <mailto:caravan@:(%7b.@:(0&(%7b::))> caravan@:({.@:(0&({::)) ; 
>> > an@:>@:{:) f.

>> >    u (+:`*:;i.5)

>> > 0 2 4 6 8

>> >

>> > I find train more intuitive but agenda more suitable for heavy duty.

>> >

>> >

>> > On Fri, Jan 30, 2015 at 9:30 AM, Joe Bogner < <mailto:[email protected]> 
>> > [email protected]>

>> wrote:

>> >

>> >> I hear a faint whisper calling me to this dark side...

>> >>

>> >> I have seen these posts[1] when I had just started using J and didn't

>> >> understand them. I went down the rabbit hole for a few hours this

>> >> morning

>> >>

>> >> The first post in the list was particularly enlightening

>> >>

>> >> NB. was gfy in Dan's post

>> >> an=. <@:((,'0') ,&< ])

>> >>

>> >> NB. 2 + i.5

>> >>    ((an 2);'+';(an i. 5);'*:') @. (0 1 2)

>> >> 2 3 4 5 6

>> >>

>> >> NB. Let's square everything

>> >>    ((an 2);'+';(an i. 5);'*:') @. (3 0 1 2)

>> >> 4 9 16 25 36

>> >>

>> >> NB. You can even see syntax errors, which can help debugging

>> >> ((an 2);'+';(an i. 5);'*:') @. (0 1 1 1)

>> >> |syntax error

>> >> |       2+++

>> >>

>> >> Let's get some more syntax errors:

>> >>

>> >> ((an 2);'+';(an i. 5);'*:') @. (3#(3 0 1 2))

>> >> |syntax error

>> >> |       *:*:*:2 2 2+++0 1 2 3 4 0 1 2 3 4 0 1 2 3 4

>> >>

>> >>

>> >> NB. +: +: +: +: (2+i.5)

>> >> ((an 2);'+';(an i. 5);'+:') @. ((4#3),(0 1 2))

>> >> 32 48 64 80 96

>> >>

>> >>

>> >> NB. adverbs too

>> >>    ('+';'/';(an i.5)) @. (0 1 2)

>> >> 10

>> >>

>> >> add1=.1&+

>> >> ((ar 'add1');(an (2 4 6))) @. (0 1)

>> >> 3 5 7

>> >>

>> >> And then coming back around to my original question:

>> >>

>> >> ((ar 'add1');'+:';(an (2 4 6))) @. (0 1 0 2)

>> >> 7 11 15

>> >>

>> >> versus this monstrosity (beware of linebreaks)

>> >> gapply=:([: >@:}. (([: }. >&{.) ; >@:{.@:>@:{. 128!:2

>> >> >@:}.)^:( <mailto:%7b.@:$@:%3e@:%7b.)> {.@:$@:>@:{.))

>> >>

>> >> gapply ('1&+';'+:';'1&+');(2 4 6)

>> >> 7 11 15

>> >>

>> >> The agenda trick doesn't quite solve the problem though due to train

>> >> formation rules:

>> >>

>> >> gapply ('1&+';'+:';'1&+';'1&+');(2 4 6)

>> >> 8 12 16

>> >>

>> >> ((ar 'add1');'+:';(an (2 4 6))) @. (0 1 0 0 2)

>> >> 9 13 17

>> >>

>> >> You train verb worked well though as an alternative

>> >>

>> >> Thank you!

>> >>

>> >> [1] -

>> >>  <http://www.jsoftware.com/pipermail/programming/2013-March/031883.html> 
>> >> http://www.jsoftware.com/pipermail/programming/2013-March/031883.html

>> >> [2] -

>> >>

>>  <http://www.jsoftware.com/pipermail/programming/2013-January/031236.html> 
>> http://www.jsoftware.com/pipermail/programming/2013-January/031236.html

>> >>

>> >> On Thu, Jan 29, 2015 at 5:55 PM, Jose Mario Quintana

>> >> < <mailto:[email protected]> [email protected]> 
>> >> wrote:

>> >> > "Is it possible to define f tacitly?"

>> >> >

>> >> > J tacit programming is Turing complete; thus, any verb can be defined

>> >> > tacitly.  It can be difficult sometimes but this case is easy... If

>> one

>> >> is

>> >> > prepared to venture to the dark side.

>> >> >

>> >> >

>> >> >    an=. <@:((,'0') ,&< ])

>> >> >

>> >> >    NB. Dark side of the force...

>> >> >

>> >> >    Cloak=. ((5!:1)@:<'Cloak')Cloak=. (0:`)(,^:)

>> >> >    ( train=. (Cloak <'`:')&6 )  NB. `:6 verbalized

>> >> > ,^:(0:``:)&6

>> >> >

>> >> >    v=.  <mailto:train@:(%7b.@:(0&(%7b::))> train@:({.@:(0&({::)) ; 
>> >> > an@:>@:{:) f.

>> >> >

>> >> >

>> >> >    v (+:`*:;i.5)

>> >> > 0 2 4 6 8

>> >> >

>> >> >

>> >> > On Thu, Jan 29, 2015 at 1:20 PM, Joe Bogner < 
>> >> > <mailto:[email protected]> [email protected]>

>> wrote:

>> >> >

>> >> >> Is it possible to define f tacitly?

>> >> >>

>> >> >> f=: 3 : '( <mailto:%7b.@:%3e@:%7b.y)%60:0> {.@:>@:{.y)`:0 (>@:}.y)'

>> >> >> f (+:`*:;i.5)

>> >> >>

>> >> >> 0 2 4 6 8

>> >> >>

>> >> >> It's meant to take the first gerund from a box that contains a list

>> of

>> >> >> gerunds and data to operate on

>> >> >>

>> >> >> It's an odd circumstance that needed it. I could probably rework the

>> >> >> logic but now I'm curious if it can be done

>> >> >>

>> >> >> Some things I tried:

>> >> >>

>> >> >> a=:(+:`*:;i.5)

>> >> >>

>> >> >> f1=:{.@:>@:{.

>> >> >>    f1 a

>> >> >> ┌──┐

>> >> >> │+:│

>> >> >> └──┘

>> >> >>

>> >> >> f2=:>@:}.

>> >> >>   f2 a

>> >> >> 0 1 2 3 4

>> >> >>

>> >> >>

>> >> >> Tried various version of combining f1 and f2 to no avail

>> >> >>

>> >> >> This works:

>> >> >>

>> >> >>    g`:0 f2 a [ g=. f1 a

>> >> >> 0 2 4 6 8

>> >> >>

>> >> >> I'm thinking there might be a way to do it without the assignment?

>> >> >>

>> ----------------------------------------------------------------------

>> >> >> For information about J forums see

>>  <http://www.jsoftware.com/forums.htm> http://www.jsoftware.com/forums.htm

>> >> >

>> ----------------------------------------------------------------------

>> >> > For information about J forums see

>>  <http://www.jsoftware.com/forums.htm> http://www.jsoftware.com/forums.htm

>> >> ----------------------------------------------------------------------

>> >> For information about J forums see  <http://www.jsoftware.com/forums.htm> 
>> >> http://www.jsoftware.com/forums.htm

>> >>

>> > ----------------------------------------------------------------------

>> > For information about J forums see  <http://www.jsoftware.com/forums.htm> 
>> > http://www.jsoftware.com/forums.htm

>> ----------------------------------------------------------------------

>> For information about J forums see  <http://www.jsoftware.com/forums.htm> 
>> http://www.jsoftware.com/forums.htm

>> 

> 

> 

----------------------------------------------------------------------

For information about J forums see  <http://www.jsoftware.com/forums.htm> 
http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------

For information about J forums see  <http://www.jsoftware.com/forums.htm> 
http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to