How would you go about reshaping a length-N
1D array into an (N/2) x 2
array? In numpy, for example, you can use -1
in place of N/2
when reshaping:
<code>>>> x = np.array([1,2,3,4])
>>> x.reshape((-1, 2))
array([[1, 2],
[3, 4]])
</code>
<code>>>> x = np.array([1,2,3,4])
>>> x.reshape((-1, 2))
array([[1, 2],
[3, 4]])
</code>
>>> x = np.array([1,2,3,4])
>>> x.reshape((-1, 2))
array([[1, 2],
[3, 4]])
So I’m wondering if there’s a J equivalent. It feels clunky to explicitly calculate the required number of rows.