StringTools - Maple Programming Help

Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Character Class Tests : StringTools/IsBinaryDigit

StringTools

 IsBinaryDigit
 determine if a character is a binary digit
 IsHexDigit
 determine if a character is a hexadecimal digit
 IsOctalDigit
 determine if a character is an octal digit

 Calling Sequence IsBinaryDigit(char) IsHexDigit(char) IsOctalDigit(char)

Parameters

 char - string; character to test

Description

 • The IsBinaryDigit(char) command determines whether char is a binary digit. A character is a binary digit if it is one of "0" or "1".
 If char is a binary digit, IsBinaryDigit returns true. Otherwise, false is returned.
 • The IsHexDigit(char) command determines whether char is a hexadecimal digit. A character is a hexadecimal digit if it is  one of the characters

 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, A, B, C, D, E, F.

 If char is a hexadecimal digit, IsHexDigit returns true. Otherwise, false is returned.
 • The IsOctalDigit(char) command determines whether char is an octal digit. A character is an octal digit if it is one of the characters

 0, 1, 2, 3, 4, 5, 6, 7.

 If char is an octal digit, IsOctalDigit returns true. Otherwise, false is returned.
 • For each of these functions, if char is a string that contains more than one character, then all the characters in the string are tested.
 Note: These commands return the value true whenever the condition tested for is true of all characters in the input string. For the empty string, the tested condition is vacuously true for all characters in the string.

 • The StringTools[IsBinaryDigit], StringTools[IsHexDigit] and StringTools[IsOctalDigit] commands are thread-safe as of Maple 15.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $s≔\mathrm{convert}\left(\left[\mathrm{}\left(1..255\right)\right],'\mathrm{bytes}'\right):$
 > $\mathrm{length}\left(s\right)$
 ${255}$ (1)
 > $\mathrm{Select}\left(\mathrm{IsHexDigit},s\right)$
 ${"0123456789ABCDEFabcdef"}$ (2)
 > $\mathrm{Select}\left(\mathrm{IsBinaryDigit},s\right)$
 ${"01"}$ (3)
 > $\mathrm{Select}\left(\mathrm{IsOctalDigit},s\right)$
 ${"01234567"}$ (4)