There is this useful essay
http://code.jsoftware.com/wiki/Essays/Parentheses_Matching
but consider,
depth =: [: +/\ =/\@(''''&~:) * 1 _1 0 {~ '()' i. ]
depth '(a(bdc)g)gg(ffff)'
1 1 2 2 2 2 1 1 0 0 0 1 1 1 1 1 0
my goal is to box an expression such that at the "top level", at least 3 boxes
are generated
'outside (' ; 'inside outer ()' ; 'outside ) and outside next top level ('
optionally followed by even number of boxes corresponding to last 2 conditions.
the most straightforward path I see is to create an argument to <;._2 sucht
that:
F depth '(a(bdc)g)gg(ffff)'
1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1
and where,
1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 1 ((<;._2) ' ' ,~ ]) '(a(bdc)g)gg(ffff)'
┌┬───────┬──┬────┬┐
││a(bdc)g│gg│ffff││
└┴───────┴──┴────┴┘
what is F?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm