On Mon, Aug 24, 2009 at 3:32 PM, Dan Bron<[email protected]> wrote:
> I needed to represent a "nested list" like this:
>
> NEST =. ;: '(345 * _2 + +/@:(+/%#) * ]) - ''hello''"_ , <.'
>
> as analogously-nested set of boxes, like this:
...
I am wondering if a different style of nesting might be
suitable.
For example:
NEST=: ;: '(345 * _2 + +/@:(+/%#) * ]) - ''hello''"_ , <.'
depth=: [: (-...@+./ #"1 i...@#@{. ,: 1 + 1 _1 +/\@:+/ .* ]) =/~&(;:'()')
group=: +/\"1@(+. _1|.!.1"1])@(>:/~ i.@(>./))@{:
gather=: [: ({."1 </. }."1)^:(1 < {:@$)L:0^:3 group |:@}.@, {...@]
nest=: ,L:0@ gather@ depth
nest NEST
+--------------------------------+----+----+----+----+----+----+
|+-+-+-+-+-+-+-+----------+--+--+|+--+|+--+|+--+|+--+|+--+|+--+|
||1|2|3|4|5|6|7|9 10 11 12|14|15|||17|||18|||19|||20|||21|||22||
|+-+-+-+-+-+-+-+----------+--+--+|+--+|+--+|+--+|+--+|+--+|+--+|
+--------------------------------+----+----+----+----+----+----+
This implementation is a bit round-about, but is the underlying
concept valid for you?
Thanks,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm