Thanks for both.
Adding spaces for readability.
3 (<"1@(,.~ i.@{.@$) +:@{`[`]} ])i. 4 5
the key element
3 (,.~ i.) 4
0 3
1 3
2 3
3 3
3 (,.~ i.@{.@$) i. 4 5
0 3
1 3
2 3
3 3
what is a bit confusing though is:
$ 3 (i.@{.@$) i. 4 5
0 1 2 3 4
# 3 (i.@{.@$) i. 4 5 ---returns nothing
0
Assuming you meant to apply $ monadically, and just got lucky with the sample
data :)
3 (,.~ i.@{.@$@]) i. 4 5
0 3
1 3
2 3
3 3
I do not understand how this line manages to work anyway.
3 (i.@{.@$) i. 4 5
----- Original Message -----
From: Aai <[email protected]>
To: [email protected]
Cc:
Sent: Thursday, September 19, 2013 12:42:25 PM
Subject: Re: [Jprogramming] Amend trickiness
perhaps this one
3 (<"1@(,.~i.@{.@$)+:@{`[`]} ])i. 4 5
or this one
3 +:@{`[`]}&.|: i. 4 5
On 19-09-13 18:02, Pascal Jasmin wrote:
> 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
--
Met vriendelijke groet,
@@i = Arie Groeneveld
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm