|
Calling Sequence
|
|
IsBalanced( s, left, right )
|
|
Parameters
|
|
s
|
-
|
string; string to test
|
left
|
-
|
character; left fence character
|
right
|
-
|
character; right fence character
|
|
|
|
|
Description
|
|
•
|
The IsBalanced(s,left,right) command checks whether the string s is balanced with respect to fence characters left and right. The characters left and right must be distinct, but are otherwise unrestricted.
|
•
|
Typical fence characters include, but are not limited to, braces ( and ), parentheses ( and ), brackets ( and ) and scare quotes ( and ).
|
•
|
The string s is deemed balanced with respect to the given fence characters if each open fence in left is matched by a subsequent, corresponding close fence in right within s. Note that it is not sufficient that corresponding fences be equal in number in s.
|
•
|
If s is the empty string, or left and right are empty strings, the command returns true.
|
•
|
All of the StringTools package commands treat strings as (null-terminated) sequences of -bit (ASCII) characters. Thus, there is no support for multibyte character encodings, such as unicode encodings.
|
|
|
Examples
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
| (5) |
>
|
|
>
|
|
>
|
|
| (7) |
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
|
|
|