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

Reply via email to