1 0 1 +/ .* 10 100 1000 1010 The dot product is arguably a key feature of J. This allows you to multiply matrices:
1+i.2 3 1 2 3 4 5 6 7+i.3 2 7 8 9 10 11 12 (7+i.3 2)+/ .*1+i.2 3 39 54 69 49 68 87 59 82 105 Note also that you can often use %. to go the other way: ((7+i.3 2)+/ .*1+i.2 3)%.7+i.3 2 1 2 3 4 5 6 But let's save that issue for later... Anyways, what . does is pair up the last dimension of the argument on the left with the first dimension of the argument on the right - combining things with the verb on the right and then applying the verb on the left to that. For example: 7 8 +/ .* 1+i.2 3 39 54 69 7 8 * 1+i.2 3 7 14 21 32 40 48 +/7 8 * 1+i.2 3 39 54 69 And we can do the same thing with the other rows of 7+i.3 2: +/9 10 * 1+i.2 3 49 68 87 +/11 12 * 1+i.2 3 59 82 105 And you can see all of these in the result: (7+i.3 2)+/ .*1+i.2 3 39 54 69 49 68 87 59 82 105 Other operations are also possible. For example we can detect collisions between binary lists using *. 0 1 0 1 *. 0 0 1 1 0 0 0 1 Or, of course, we could do exactly the same thing with * 0 1 0 1 * 0 0 1 1 0 0 0 1 And we can check if there were any collisions using +./ +./ 0 1 0 1 * 0 0 1 1 1 So basically, it's just: dot=:2 :'u@(v"1 _)' And u is usually formed using the / adverb. I hope this helps, but I suspect I'm not doing a very good job of describing the process. Oh well... -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
