[Jprogramming] Gerund composed application
Jose Mario Quintana
jose.mario.quintana at gmail.com
Sun Sep 24 16:09:56 UTC 2017
an=. <@:((,'0') (,&:<) ]) NB. Atomizing words (monadic verb)
f=. '(x , an y)`:6' (dyad :) NB. Explicit compliant version
(*:`+:) f 4
64
train=. (<'`:')(0:`)(,^:)&6
f=. train@:([ , an@:]) f. NB. Non-compliant fixed tacit version
(*:`+:) f 4
64
f=. "..@:([ , "..inv@:]) NB. Non-compliant fixed tacit Jx version
(*:`+:) f 4
64
On Sun, Sep 24, 2017 at 6:43 AM, Rob Moore <robmoore121 at gmail.com> wrote:
> Hi guys,
>
> I am wondering if there already exists a way of doing something that I
> want, which is an elementary enough operation that I was quite surprised to
> not have found it in jvoc/evoke gerund.
>
>
> If I have some gerund say *:`+: I am looking for some function which will
> apply the gerund's constituents in order (from right to left of course)
> monadically to some noun.
>
>
> For example '(*:`+:) f 4' should be equivalent to '*: +: 4' (which is 64)
>
>
> My current solution is functional but unsatisfactory. Convert gerund to
> string, append the (string) argument and then apply 'do' ".
>
>
> composeGerund=:".@:((,@:(,"1&' ')@:>@:[) , ])
>
>
> e.g:
>
>
> gerund=:*:`+:
>
> , ,"1&' ' >gerund
>
> *: +:
>
> (, ,"1&' ' >gerund) , '4'
>
> *: +: 4
>
> ". (, ,"1&' ' >gerund) , '4'
>
> 64
>
>
> I don't want to have to specify my right argument as a string, I want to
> pass in variables by value!
>
>
> Does anyone have a good solution?
>
>
> Cheers,
>
>
> Rob
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list