1 2 3 + 4 5 6 7
|length error
| 1 2 3 +4 5 6 7
In general - depends on the operation. Sometimes the verb checks that both operands have the same rank and dimensions, sometimes the shorter/smaller side gets applied column-wise (or cell-wise/page-wise): (2 2 $ 1 2 3 4) NB. $ means "reshape"
1 2
3 4
(2 2 $ 1 2 3 4) + 1 2
2 3
5 6
Sometimes the shorter side is repeated as much as needed to get the correct length, and sometimes the shorter side gets extended with 0s, and sometimes the longer side gets truncated: (2 2 $ 1 2 3 4 5 6)
1 2
3 4
(2 4 $ 1 2 3 4 5 6)
1 2 3 4
5 6 1 2
To be perfectly honest: it's very unintuitive to me and I have to check the docs pretty often to see how the given verb behaves outside of the simplest case (ie. when the rank and dimensions match). But, I learned J as a hobby and never invested enough time into it to really learn all the built-ins, nor did I try using J outside of toy examples, so maybe this behavior becomes convenient once you internalized it?EDIT: forgot to mention, you can also control the effective rank of the verb, like this:
<"0 (2 2 $ 1 2 3 4)
┌─┬─┐
│1│2│
├─┼─┤
│3│4│
└─┴─┘
<"1 (2 2 $ 1 2 3 4)
┌───┬───┐
│1 2│3 4│
└───┴───┘
<"2 (2 2 $ 1 2 3 4)
┌───┐
│1 2│
│3 4│
└───┘
the `<` verb means "box", without the `"n` part you'd get the last value, which is a 1-dimensional array of boxes of length 1 (with 2x2 array inside the box). By selecting rank of the verb, you can decide on which level the verb should be applied: with `"0` it's applied to the smallest possible chunks of the array (cells - you get 2x2 array of boxes), with `"1` you apply the verb to bigger chunks (rows), and so on, for input arrays of any dimensions (so if you have a 3x2x2 array, `"2` will apply the verb to the 3 2x2 arrays).