@RebeccaSkinner
As is, isBalanced
would for example consider “Hello)(” as balanced. This can be easily fixed by freezing count
at -1 as soon as the count drops below 0 (same for second version on p.52). Maybe there is a more elegant solution. So here is my proposal:
isBalanced' count s
| null s = count
| count < 0 = count
| ...