I overlooked the following,

"
I was experimenting with a way to apply a series of verbs to an argument

f(g(h(arr)))
"

   JVERSION
Installer: j602a_win.exe
Engine: j803/2014-10-19-11:11:11
Library: 6.02.023

Using the same previous verbs,

   an=. <@:((,'0') ,&< ])
   Cloak=. ((5!:1)@:<'Cloak')Cloak=. (0:`)(,^:)
   train=. (Cloak <'`:')&6  NB. `:6 verbalized

One can produce,

   gtn=. train@:([ , an@:]) f.
   tgn=. gtn&:>/ f.

How do the different verbs compare?

   gapplye=. ;@:}.@:(3 : '(([: }. >&{.)y);(({.@:>&{.y)`:0
(>&}.y))'^:({.@:$@:>@:{.))
     NB. A pro-verb for Joe's explicit version


   gapplye (1&+)`+:`(1&+)     ; 2 4 6
7 11 15
   gapply  ('1&+';'+:';'1&+') ; 2 4 6
7 11 15
   tgn     (1&+)`+:`(1&+)     ; 2 4 6
7 11 15

   type &> ;:'gapplye gapply tgn'
┌────┬────┬────┐
│verb│verb│verb│
└────┴────┴────┘
   (7!:5) &: ;: 'gapplye gapply tgn'  NB. Space used by the pro-verbs
3200 3968 7424

   1000 st&> 'gapplye (1&+)`+:`(1&+) ; 2 4 6' ; 'gapply
(''1&+'';''+:'';''1&+'') ; 2 4 6' ; 'tgn (1&+)`+:`(1&+) ; 2 4 6'
┌─────────────────────────────────┬─────┬──────────┬─────────┐
│gapplye (1&+)`+:`(1&+) ; 2 4 6   │13056│3.74022e_5│0.488323 │
├─────────────────────────────────┼─────┼──────────┼─────────┤
│gapply ('1&+';'+:';'1&+') ; 2 4 6│6528 │9.7345e_6 │0.0635468│
├─────────────────────────────────┼─────┼──────────┼─────────┤
│tgn (1&+)`+:`(1&+) ; 2 4 6       │8960 │7.35112e_6│0.065866 │
└─────────────────────────────────┴─────┴──────────┴─────────┘

Also,

"
Jan-Pieter Jacobs had an cleaner approach:

[ at =: 1 : '(,@(({.''''`[:)&,.)@}: , {:) m'
(1&+)`+:`(1&+) at `:6 (2,4,6)
7 11 15
"

   gapplyn=. 'at'f. (`:6)  NB. A pro-adverb for Jan-Pieter`s adverb

   (1&+)`+:`(1&+) gapplyn 2 4 6
7 11 15
   (1&+)`+:`(1&+) gtn     2 4 6
7 11 15

   type &> ;:'gapplyn gtn'
┌──────┬────┐
│adverb│verb│
└──────┴────┘
   (7!:5) &: ;: 'gapplyn gtn'  NB. Space used by the pro-adverb and the
pro-verb
1920 3072

   1000 st&> '(1&+)`+:`(1&+) gapplyn 2 4 6' ; '(1&+)`+:`(1&+) gtn 2 4 6'
┌────────────────────────────┬─────┬──────────┬─────────┐
│(1&+)`+:`(1&+) gapplyn 2 4 6│10496│9.40707e_6│0.0987366│
├────────────────────────────┼─────┼──────────┼─────────┤
│(1&+)`+:`(1&+) gtn 2 4 6    │8320 │6.16125e_6│0.0512616│
└────────────────────────────┴─────┴──────────┴─────────┘



On Thu, Jan 29, 2015 at 2:37 PM, Joe Bogner <[email protected]> wrote:

> For laughs or face palming:
>
> I was experimenting with a way to apply a series of verbs to an argument
>
> f(g(h(arr)))
>
> I didn't want it to follow any rules of a train
>
> This was my best explicit attempt:
>
> ; }. (3 :'(([: }. >&{.)y);(({.@:>&{.y)`:0 (>&}.y))')^:(({.@:$@:>@:{.))
> ((1&+)`+:`(1&+);(2 4 6))
> 7 11 15
>
> (1+(2*(1+2))), (1+(2*(1+4))), (1+(2*(1+6)))
>
>
> Explicit:
>
> f1=:([: }. >&{.)
> f2=: (>@:{.@:>@:{.) apply >@:}.
> f3=: ({.@:$@:>@:{.)
> gapply=: [: >@:}. (f1 ; f2)^:(f3) f.
>
> gapply ('1&+';'+:';'1&+');(2 4 6)
> 7 11 15
>
> gapply
> [: >@:}. (([: }. >&{.) ; >@:{.@:>@:{. 128!:2 >@:}.)^:({.@:$@:>@:{.)
>
> One minor difference in 128!:2 is that it takes a string and not a
> gerund, which is not interchangeable in the case of 1&+
>
> Jan-Pieter Jacobs had an cleaner approach:
>
> [ at =: 1 : '(,@(({.''''`[:)&,.)@}: , {:) m'
> (1&+)`+:`(1&+) at `:6 (2,4,6)
> 7 11 15
>
>
> On Thu, Jan 29, 2015 at 2:06 PM, Raul Miller <[email protected]>
> wrote:
> > Another approach uses, for example, ]^:] with an introspecting gerund.
> >
> > Needless to say, this is more complex than the explicit form. But you
> > can transform nouns to nouns with verbs and gerunds are nouns.
> >
> > Thanks,
> >
> > --
> > Raul
> >
> >
> >
> > On Thu, Jan 29, 2015 at 1:55 PM, Joe Bogner <[email protected]> wrote:
> >> Cool, I was just on
> >> http://jsoftware.com/jwiki/PascalJasmin/tacit%20programming%20functions
> >> trying to figure out how to apply it to this problem. I figured you'd
> >> have a solution. Thanks!
> >>
> >> On Thu, Jan 29, 2015 at 1:48 PM, 'Pascal Jasmin' via Programming
> >> <[email protected]> wrote:
> >>> gerund and non-gerund solution,
> >>>
> >>>
> >>> Y =: 1 : '(m&{::@:])'
> >>>
> >>>   (( 0 Y 0 Y) apply 1 Y )  (+:`*:;i.5)
> >>> 0 2 4 6 8
> >>>   (( 0 Y 0 Y) apply 1 Y )  ((;: '+: *:');i.5)
> >>> 0 2 4 6 8
> >>>
> >>>
> >>> trickier for dyadic
> >>>
> >>> '2&' (1 Y apply~ [ , ] 0 Y 0 Y)  ((;: '+ *:');i.5)
> >>> 2 3 4 5 6
> >>>
> >>>
> >>>
> >>> ________________________________
> >>> From: Joe Bogner <[email protected]>
> >>> To: [email protected]
> >>> Sent: Thursday, January 29, 2015 1:20 PM
> >>> Subject: [Jprogramming] conjunction in tacit verb
> >>>
> >>>
> >>> Is it possible to define f tacitly?
> >>>
> >>> f=: 3 : '({.@:>@:{.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
> >>> ----------------------------------------------------------------------
> >>> 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

Reply via email to