Balanced brackets: Difference between revisions

Content added Content deleted
(Replace println() with print(); replace output "syntaxhighlight" tag with "pre" tag)
m (Fixed bug)
Line 3,335: Line 3,335:
include "NSLog.incl"
include "NSLog.incl"


local fn BracketBalance( strWithBrackets as CFStringRef ) as CFStringRef
local fn BracketBalance( strWithBracket as CFStringRef ) as CFStringRef
NSInteger i, bracketTracker = 0
NSInteger i, bracketTracker = 0
CFStringRef result
CFStringRef result
Line 3,341: Line 3,341:
CFCharacterSetRef bracketSet = fn CharacterSetWithCharactersInString( @"[]" )
CFCharacterSetRef bracketSet = fn CharacterSetWithCharactersInString( @"[]" )
CFCharacterSetRef bracketsOnlySet = fn CharacterSetInvertedSet( bracketSet )
CFCharacterSetRef bracketsOnlySet = fn CharacterSetInvertedSet( bracketSet )
CFStringRef trimmedStr = fn StringByTrimmingCharactersInSet( strWithBrackets, bracketsOnlySet )
CFArrayRef trimmedSArray = fn StringComponentsSeparatedByCharactersInSet( strWithBracket, bracketsOnlySet )
CFStringRef trimmedStr = fn ArrayComponentsJoinedByString( trimmedSArray, @"" )
NSUInteger strLen = len( trimmedStr )
NSUInteger strLen = len( trimmedStr )