"
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 1@:({.@:(0&({::)) ; an@:>@:{:) f.
u (+:`*:;i.5)
0 2 4 6 8
Alternatively,
caravan=. agenda&0@:<
u=. 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 <[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
> >@:}.)^:({.@:$@:>@:{.))
>
> 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
> [2] -
> http://www.jsoftware.com/pipermail/programming/2013-January/031236.html
>
> On Thu, Jan 29, 2015 at 5:55 PM, Jose Mario Quintana
> <[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=. train@:({.@:(0&({::)) ; an@:>@:{:) f.
> >
> >
> > v (+:`*:;i.5)
> > 0 2 4 6 8
> >
> >
> > On Thu, Jan 29, 2015 at 1:20 PM, Joe Bogner <[email protected]> wrote:
> >
> >> 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