IsBalanced - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


StringTools

  

IsBalanced

  

determine if fences in a string are balanced

 

Calling Sequence

Parameters

Description

Examples

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

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(8)

(9)

(10)

(11)

(12)

(13)

(14)

(15)

(16)

(17)

(18)

(19)

(20)

See Also

string

StringTools

 


Download Help Document