[Jprogramming] Amend trickiness

Pascal Jasmin godspiral2000 at yahoo.ca
Thu Sep 19 16:02:43 UTC 2013


   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?


More information about the Programming mailing list