I have a program that is supposed to match brackets ( [,), and } ) but also correct nesting. I have the matching part done, but I can't seem to think of a way to check nesting. If the input string is: ([)] , my program as of now, will return "good" because there are equal number of closing brackets for an opening bracket of the same type, but the nesting arangement is bad. anyway I can do this?
should catch it as soon as the string closes out a bracket on the interior that is, itself, not closed:
( -> ( [ -> ( [ ) "Bad"
Edit/Delete Message
I'm thinking if I do a series of if statements, I could get it working. But I've been toying with if statements on paper for the past hour and if I do it this way, it'll be about 100 lines of code by itself!
(Code available for PM)
should catch it as soon as the string closes out a bracket on the interior that is, itself, not closed:
( -> ( [ -> ( [ ) "Bad"
Edit/Delete Message
I'm thinking if I do a series of if statements, I could get it working. But I've been toying with if statements on paper for the past hour and if I do it this way, it'll be about 100 lines of code by itself!
(Code available for PM)