Turns out the result was as expected but the arrays I was using were not
proper.

I should have used arrays of random numbers in my tests.

   ]a=.?2 3 5$100
63 76 45 83 60
97 75 88 89 84
84 90 93 78 31

24 91 99 27 52
25 87 67 97 11
95 85 78 53 90
   ]b=. ?2 3$100
11 54  4
81 96 54


An error would have ben detected and my line would have ended up as:

   b    (2&{"1@i.@$@])}a
63 76 11 83 60
97 75 54 89 84
84 90  4 78 31

24 91 81 27 52
25 87 96 97 11
95 85 54 53 90

The two lines of b are inserted into a, not just in a special case.

And the more readable version still would not work, probably for the reason
you mentioned.

Sent from my iPad

On 2012-05-19, at 00:14, Ric Sherlock <tikk...@gmail.com> wrote:

The key difference between the two expressions is that ( c ) is a noun
and ( 2&{"1@] ) is  a verb

  d=: 2&{"1@]
  type ;:'c d'
┌────┬────┐
│noun│verb│
└────┴────┘

So the form of amend you are using is different in the two cases ( m}
) cf ( u} ).
You get an index error using ( c ) because it is interpreting the
integers in ( c ) as indicies of ( a ) and ( a ) doesn't have matching
items for some of the big numbers in ( c ).

On Sat, May 19, 2012 at 11:30 AM, Robert Cyr <robert....@gmail.com> wrote:

Inserting a 2 column array in a specified  column of a rank 3 array.


*Given*:


  a=.i.2 3 5

  b=.i.2 3

  ]c=.2{"1 a

 2  7 12

17 22 27


*This one is fine:*


  b(2&{"1@])}a

 0  1 0  3  4

 5  6 1  8  9

10 11 2 13 14


15 16 3 18 19

20 21 4 23 24

25 26 5 28 29


*But not this quite similar one*:

  b c }a

|index error

|   b     c}a


*Why?*



Sent from my iPad

----------------------------------------------------------------------

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