<"1 &. |:  i. 5 3
┌──────────┬───────────┬───────────┐
│0 3 6 9 12│1 4 7 10 13│2 5 8 11 14│
└──────────┴───────────┴───────────┘

  (3) (2)} L:0  <"1 &. |:  i. 5 3
┌──────────┬───────────┬───────────┐
│0 3 3 9 12│1 4 3 10 13│2 5 3 11 14│
└──────────┴───────────┴───────────┘

but:

  (3) (2)} L:0  (1}) |: <"1 |:  i. 5 3
┌───────────┐
│1 4 3 10 13│
└───────────┘

updates (and returns) just the middle cell instead of returning the whole data.

I would have hoped that the right approach was:

   3 [L:0(2})`1:`]} |: <"1 |:  i. 5 3
┌─┐
│3│
└─┘

but no.



----- Original Message -----
From: Pascal Jasmin <[email protected]>
To: "[email protected]" <[email protected]>
Cc: 
Sent: Thursday, September 19, 2013 12:02:43 PM
Subject: [Jprogramming] Amend trickiness

   6 (3}"1) i.4 5
 0  1  2 6  4
 5  6  7 6  9
10 11 12 6 14
15 16 17 6 19

  +:  (3}"1) i.4 5
6 16 26 36

I'd wish for the result to return the full row/table as the first amend.  I'd 
also like the code to the left of the amend to not know how many rows there 
are.  There is possibly a gerund approach I don't understand

I've read this page http://www.jsoftware.com/jwiki/JPhrases/MergeAmend
and it recommends making an unravelling adverb, and then applying a known shape 
(ur 2_3) to select, but basically the general workaround approach that seems to 
be recommended.

IR=: @(i.@$@])

new=. +: 3{"1 ] i.4 5    or to add rows 1 and 2 ((0&{+1&{))"1
sel=. 3&{"1 IR  i.4 5
rows =. # i.4 5

then to do the update,

(rows , 5) $ new sel} , i.4 5

to avoid 
(rows , 5) $ (+:@(3&{)"1 sel} ,) i. 4 5


   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?
----------------------------------------------------------------------
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