Hi Bob, I hope this doesn't confuse the situation more (and I hope i am right in this information), but it is worth keeping in mind that the adverb Insert (/), inserts the verb between the ITEMS of whatever argument it is working on. So /"1 works on lists and inserts the verb between atoms, /"2 works on blocks and inserts its verb between lists. This means that /"1 will total a row and /"2 will total the columns.
*"1/ on the other hand applies * between lists (as long as the argument items are of rank 1, remember the verb is now *"1 but the / adverb still applies the verb between items of its argument). Henry Rich's chapter 6 in J for C programmers is really a good read for how ranks work. Link: http://www.jsoftware.com/help/jforc/loopless_code_i_verbs_have_r.htm#_Toc191734331 Hope that helps. cheers, bob On -Apr29-2010, at -Apr29-20101:38 PM, Robert O'Boyle wrote: > II have come across a feature of J that I didn't expect. When I add rows of > a matrix, I use +/"1 > > a > > 1 2 3 4 > > 1 2 3 4 > > 1 2 3 4 > > > > +/"1 a > > 10 10 10 > > > > And columns, > > +/"2 a > > 3 6 9 12 > > > > By chance, I happened to 'misplace' insert and got an unexpected result > > > > +"1/a > > 3 6 9 12 > > > > which is the addition of the columns. However, > > > > +"2/ a > > 3 6 9 12 > > > > Now take another matrix b > > b > > 1 1 1 1 > > 2 2 2 2 > > 3 3 3 3 > > 4 4 4 4 > > > > I would like to multiply every row of b by every row of a, but > > > > a*/"1 b > > |length error > > | a */"1 b > > > > While > > > > a*"1 / b > > 1 2 3 4 > > 2 4 6 8 > > 3 6 9 12 > > 4 8 12 16 > > > > 1 2 3 4 > > 2 4 6 8 > > 3 6 9 12 > > 4 8 12 16 > > > > 1 2 3 4 > > 2 4 6 8 > > 3 6 9 12 > > 4 8 12 16 > > > > Which appears to work. > > > > I am obviously missing something with rank and insert. Could someone > enlighten me? Any insight is much appreciated, as always. > > > > Bob > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm