If I do not know the shape of items in advance, how would I box each item? one case that breaks ;/ is
<"1 (;~"0 i.5) NB. what I want ┌─────┬─────┬─────┬─────┬─────┐ │┌─┬─┐│┌─┬─┐│┌─┬─┐│┌─┬─┐│┌─┬─┐│ ││0│0│││1│1│││2│2│││3│3│││4│4││ │└─┴─┘│└─┴─┘│└─┴─┘│└─┴─┘│└─┴─┘│ └─────┴─────┴─────┴─────┴─────┘ ;/ i.5 ┌─┬─┬─┬─┬─┐ │0│1│2│3│4│ └─┴─┴─┴─┴─┘ ;/ (;~"0 i.5) ┌─────┬─────┬─────┬─────┬─┬─┐ │┌─┬─┐│┌─┬─┐│┌─┬─┐│┌─┬─┐│4│4│ ││0│0│││1│1│││2│2│││3│3││ │ │ │└─┴─┘│└─┴─┘│└─┴─┘│└─┴─┘│ │ │ └─────┴─────┴─────┴─────┴─┴─┘ This seems to work. boxitems =: (<"0)`(<"1)@.(1<#@$) boxitems (;~"0 i.5) ┌─────┬─────┬─────┬─────┬─────┐ │┌─┬─┐│┌─┬─┐│┌─┬─┐│┌─┬─┐│┌─┬─┐│ ││0│0│││1│1│││2│2│││3│3│││4│4││ │└─┴─┘│└─┴─┘│└─┴─┘│└─┴─┘│└─┴─┘│ └─────┴─────┴─────┴─────┴─────┘ boxitems ( i.5) ┌─┬─┬─┬─┬─┐ │0│1│2│3│4│ └─┴─┴─┴─┴─┘ Is there a better way of defining boxitems? I have no current use for boxing above rank 2, but this could appear more useful than trying to detect rank 3. boxitems boxitems (2 5 $ ;~"0 i.5) ┌───────────────────────────────┬───────────────────────────────┐ │┌─────┬─────┬─────┬─────┬─────┐│┌─────┬─────┬─────┬─────┬─────┐│ ││┌─┬─┐│┌─┬─┐│┌─┬─┐│┌─┬─┐│┌─┬─┐│││┌─┬─┐│┌─┬─┐│┌─┬─┐│┌─┬─┐│┌─┬─┐││ │││0│0│││1│1│││2│2│││3│3│││4│4│││││0│0│││1│1│││2│2│││3│3│││4│4│││ ││└─┴─┘│└─┴─┘│└─┴─┘│└─┴─┘│└─┴─┘│││└─┴─┘│└─┴─┘│└─┴─┘│└─┴─┘│└─┴─┘││ │└─────┴─────┴─────┴─────┴─────┘│└─────┴─────┴─────┴─────┴─────┘│ └───────────────────────────────┴───────────────────────────────┘ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
