This challenge is specific to languages of the APL family. Although it might be solvable in other languages, please do not expect this to be easy as it depends on some specific concepts of this language family.
Many array oriented languages have the concept of a box (also called enclosure). A box encapsulates an array, hiding its shape. Here is an example of a boxed array:
┌─┬───────┬─────┐
│0│1 2 3 4│0 1 2│
│ │ │3 4 5│
└─┴───────┴─────┘
This array was generated from the J sentence 0 ; 1 2 3 4 ; i. 2 3
and contains three boxes, the first containing the scalar 0
, the second containing a vector of shape 4
, and the third containing a matrix of shape 2 3
.
Some arrays of boxes look like they are plain arrays broken apart by boxes:
┌─┬───────────┐
│0│1 2 3 4 │
├─┼───────────┤
│5│ 9 10 11 12│
│6│13 14 15 16│
│7│17 18 19 20│
│8│21 22 23 24│
└─┴───────────┘
The previous array was generated from the J expression 2 2 $ 0 ; 1 2 3 4 ; (,. 5 6 7 8) ; 9 + i. 4 4
.
Your goal in this challenge is to take an array like that and remove the boxes separating the subarrays from one another. For instance, the previous array would be transformed into
0 1 2 3 4
5 9 10 11 12
6 13 14 15 16
7 17 18 19 20
8 21 22 23 24
Submit a solution as a monadic verb / function. The verb must work on arrays of arbitrary rank. You may assume that the shapes of the boxed arrays fit, that is, boxed subarrays adjacent on an axis have to have the same dimensions in all but that axis. Behaviour is undefined if they don't.
This challenge is code golf. The submission compromising the least amount of characters wins.