Unique - Maple Help

StringTools

 Unique
 convert a string to a character set

 Calling Sequence Unique( s )

Parameters

 s - Maple string

Description

 • The Unique(s) command returns a string, which contains exactly one instance of each character that occurs in the input string s, using a linear time, constant space algorithm.
 • The order in which the characters appear in the output string is not defined. In particular, the value returned by Unique may differ from the input even when the input contains no duplicate characters.
 • To test whether a string s contains more than one instance of some character, use $\mathrm{IsPermutation}\left(s\right)$.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{Unique}\left("aaaaaa"\right)$
 ${"a"}$ (1)
 > $\mathrm{Unique}\left("abcabcabc"\right)$
 ${"abc"}$ (2)
 > $\mathrm{Unique}\left("cbacabbac"\right)$
 ${"abc"}$ (3)
 > $\mathrm{Unique}\left("cba"\right)$
 ${"abc"}$ (4)
 > $\mathrm{Unique}\left(\mathrm{Random}\left(1000000,'\mathrm{lower}'\right)\right)$
 ${"abcdefghijklmnopqrstuvwxyz"}$ (5)