> From: Chris Burke <[email protected]>
>
> How to check if a string has balanced [] {} ()?
>
> Any pair by itself is easy enough, but I want to check all three balance
> together, e.g.
>
> ...[(])...
>
> would fail. Assume there are no character strings.
>
> Ideally, I'd like a result of
>
> 0 = balanced
> 1 = balanced so far, but some closing delimiters to come
> 2 = unbalanced (and broken)
1. remove all non-parens
2. progressively remove "()", "[]" or "{}" while possible
empty string => balanced
none of ")]}" => balanced to come
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm