here is Raul's function translated from gerund to human :P
a2v is a utility verb that turns an adverb into a verb. definition:
a2v =: 1 : 0 NB. for dyad adverb, where adverb takes noun arg. ie (3 1,: 6 2)
'}' a2v reduce i.5
4 : ('''a b'' =. x label_. a (b(', u , ')) y')
)
} item amend takes 2 left noun parameters. '}'a2v is a verb that will parse
the 2 arguments as x and m respectively. The 3 gerunds evaluate to x m and y
respectively for the a2v version.
(([ '}' a2v~ ,@] ;~ 3##\@] ) 0 1 2 +/~I.)
----- Original Message -----
From: Joe Bogner <[email protected]>
To: [email protected]
Cc:
Sent: Wednesday, January 28, 2015 1:37 PM
Subject: Re: [Jprogramming] scan replace
Yes it does.
x=:(12#0)
y=:(1,2,3),(5,6,7),:(9,10,11)
These are equivalent:
(x (3 # #\@]) y) (x (,@]) y) } (x ([) y)
x (3 # #\@])`(,@])`([) } y
Clever
On Wed, Jan 28, 2015 at 1:10 PM, Raul Miller <[email protected]> wrote:
> Dyadic gerund amend looks like this
>
> x u0`u1`u2} y
>
> and works like this:
> (x u0 y) (x u1 y)} x u2 y
>
> (Monadic gerund amend is very different.)
>
> Does that help?
>
> Thanks,
>
> --
> Raul
>
>
> On Wed, Jan 28, 2015 at 12:59 PM, Joe Bogner <[email protected]> wrote:
>> On Tue, Jan 27, 2015 at 11:45 PM, Raul Miller <[email protected]> wrote:
>>> I guess this is how I'd write that:
>>>
>>> f=: (3##\@])`(,@])`[} 0 1 2 +/~I.
>>>
>>> Is that easy enough to read, or should I spell out how it works?
>>>
>>
>> This was enjoyable to decode. It looks simple but there are a few
>> things that I haven't used extensively.
>>
>> I still don't understand the gerund item amend.
>>
>> Here is my interpretation for others who may be interested
>>
>> * 1. First I realized it's a hook
>>
>> I tried using trace and dissect and couldn't figure it out from those
>> outputs, so then I tried
>>
>> (arr f arr) -: (f arr)
>> 1
>>
>> http://www.jsoftware.com/jwiki/Vocabulary/hook
>>
>> * 2. Knowing it was a hook I started to break it down
>>
>> The spacing threw me off a bit initially
>>
>> NB. gerund amend http://www.jsoftware.com/jwiki/Vocabulary/curlyrt#dyadic
>> u=: (3##\@])`(,@])`[ }
>> v=: 0 1 2 +/~I.
>>
>> ((u v) arr) -: (f arr)
>> 1
>>
>> (arr g (v arr)) -: (f arr)
>> 1
>>
>> * 3. Item Amend
>>
>> I haven't yet figured out how this part works
>>
>> Here's a simpler version to look at
>>
>> (12#0) ((3 # #\@])`(,@])`[}) ((1,2,3),(5,6,7),:(9,10,11))
>> 0 1 1 1 0 2 2 2 0 3 3 3
>>
>>
>> The first gerund replicates 3 times the number which corresponds to #
>> of rows in the prefix
>>
>> #\ ((1,2,3),(5,6,7),:(9,10,11))
>> 1 2 3
>>
>> The second gerund appears to yield the concatenation
>>
>> The third gerund yields the left
>>
>> I don't understand the order these gerunds get applied
>>
>> The dictionary say: "If m is a gerund, one of its elements determines
>> the index argument to the adverb } , and the others modify the
>> arguments x and y :"[1]
>>
>> The phrase that's confusing me is "one of its elements" -- which one?
>>
>> [1] http://www.jsoftware.com/help/dictionary/d530n.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