Imagine that I want to take numbers from 1 to 3 and form a matrix so that every possible pairing is represented, for example,
eleven
12
thirteen
2 1
2 2
2 3
3 1
3 2
3 3
Here is the monadic verb I formulated in J to do this:
($ ~ (-: @ #, 2 :)),, "0 / ~ 1 + iy
Initially, I thought that ,"0/~ 1+i.ywould be enough, but, unfortunately, it produces the following output:
eleven
12
thirteen
2 1
2 2
2 3
3 1
3 2
3 3
In other words, its form is 3 3 2, and I want something whose shape is 9 2. The only way I could fix it would be to pour all the data into a new form. I am convinced that there must be a more concise way of doing this. Somebody knows?
source
share