What is the best way to flatten a box array of arbitrary depth?
e.g. if I have
arr =: (< 3 4) ; (3; <'HELLO'; << 'HI'); 'WORLD' NB. just random boxes
┌─────┬────────────────┬─────┐
│┌───┐│┌─┬────────────┐│WORLD│
││3 4│││3│┌─────┬────┐││ │
│└───┘││ ││HELLO│┌──┐│││ │
│ ││ ││ ││HI││││ │
│ ││ ││ │└──┘│││ │
│ ││ │└─────┴────┘││ │
│ │└─┴────────────┘│ │
└─────┴────────────────┴─────┘
and I want to make
┌───┬─┬─────┬──┬─────┐
│3 4│3│HELLO│HI│WORLD│
└───┴─┴─────┴──┴─────┘
That is, all boxed items are moved to the top.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm