> From: Bill Harris
>
> That is, if
>
> ]a=: i. 3 4 5
> 0 1 2 3 4
> 5 6 7 8 9
> 10 11 12 13 14
> 15 16 17 18 19
>
> 20 21 22 23 24
> 25 26 27 28 29
> 30 31 32 33 34
> 35 36 37 38 39
>
> 40 41 42 43 44
> 45 46 47 48 49
> 50 51 52 53 54
> 55 56 57 58 59
>
> then I might want
>
> 2 7 12 0
> 22 27 0 0
> 42 47 52 57
>
> I know the numbers of the first row to drop (3 2 5 in that example) and
> the row I want (2 in that example); can you help me craft the argument
> to { to generate that?
>
> I'm content with zeros padding the remainder of the table, but I'll also
> take a boxed result with just the right number of entries in each box.
Here are a number of different ways, none of them as nice and simple as Henry's.
But they show how you can build a left argument for { to give you what you want.
((<0;(i.3);2),(<1;(i.2);2),(<2;(i.4);2)){a
2 7 12 0
22 27 0 0
42 47 52 57
(<"1((i.3);2),((i.2);2),:((i.4);2)){"0 2 a
2 7 12 0
22 27 0 0
42 47 52 57
(<@(2 ;~ i.)"0 ] 3 2 4) {"0 2 a
2 7 12 0
22 27 0 0
42 47 52 57
(<@(2 ;~ i.)"0 ] 3 2 4) <@{"0 2 a
+------+-----+-----------+
|2 7 12|22 27|42 47 52 57|
+------+-----+-----------+
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm