0 1&(+:@{) 2 3 4 5
4 6

I expected that.  You are right, that I would have complained to see this 
result:

    3 (0 1&(+:@{)) 2 3 4 5
16 24

Fortunately, that would only be natural  for automated code generation 
(readability and concentration makes bonding to the far right conjunction item 
the most natural), and bonding at the far right end of a conjunction/modifier 
train seems automatable too.


>From the vocabulary page,

The phrase x f@[&0 y is equivalent to f^:x y


This does not seem like a helpful feature.


----- Original Message -----
From: Raul Miller <[email protected]>
To: Programming forum <[email protected]>
Cc: 
Sent: Thursday, September 19, 2013 2:50:33 PM
Subject: Re: [Jprogramming] Amend trickiness

I think I should drop a warning flag here:

   3 (0 1&{) 2 3 5 7
2 3
   3 (0 1&(+:@{)) 2 3 5 7
16 24

http://www.jsoftware.com/help/dictionary/d630n.htm

;)

In other words, the behavior of 2 3&{ in this context might be a bit
surprising if you have oversimplified your understanding of 0 1&{

-- 
Raul

On Thu, Sep 19, 2013 at 2:25 PM, Pascal Jasmin <[email protected]> wrote:
> Thank you Raul,
>
> The other challenge... placing in column 3 the result of op on first 2 
> columns is fairly pretty your way.
>
>    3 +/@(0 1&{)`[`]}"1 i. 4 5
>  0  1  2  1  4
>  5  6  7 11  9
> 10 11 12 21 14
> 15 16 17 31 19
>
>
>
> ----- Original Message -----
> From: Raul Miller <[email protected]>
> To: Programming forum <[email protected]>
> Cc:
> Sent: Thursday, September 19, 2013 2:00:16 PM
> Subject: Re: [Jprogramming] Amend trickiness
>
> On Thu, Sep 19, 2013 at 12:02 PM, Pascal Jasmin <[email protected]> 
> wrote:
>>    4 5 $ (+:@(3&{)"1 sel} ,) i. 4 5
>>  0  1  2  6  4
>>  5  6  7 16  9
>> 10 11 12 26 14
>> 15 16 17 36 19
>>
>> is there a gerund amend version that avoids the temp assignments? or other 
>> code to get the same result?
>
> In addition to the other proposals, I think this does what you want:
>
>    3 +:@{`[`]}"1 i. 4 5
> 0  1  2  6  4
> 5  6  7 16  9
> 10 11 12 26 14
> 15 16 17 36 19
>
> Note that it can be a little confusing, working through the errors you
> get when experimenting with gerund amend. There's several verbs
> involved, and how do you determine which one is causing the problem?
>
> But you can expand out the definition and inspect what happens that
> way. For example, this was an experiment I almost used:
>
>    3 (4 :'(x{y) (x[y)} x]y'"1) i. 4 5
>
> (But I didn't actually perform that experiment because when I noticed
> that my broken code had an irrelevant ~ in it: 3 +:@{`[`]}"1~ i. 4 5)
>
> I hope this helps,
>
> --
> Raul
> ----------------------------------------------------------------------
> 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