 Random - Maple Help

StringTools

 Random
 return a random string Calling Sequence Random( len, alphabet ) Randomize( seed ); Parameters

 len - positive integer; length of string to generate alphabet - (optional) string or symbol; restricts the characters that form the string seed - (optional) integer; seed for the random number generator Description

 • The Random(len, alphabet) calling sequence generates a random string of a given length, with the option of restricting the characters that form the returned string.
 The Random(len) calling sequence returns a string of length len whose characters are randomly distributed and in the numeric range $1..255$. That is, any non-zero 8-bit character can appear, and all appear with equal likelihood.
 If the second optional argument, alphabet, is included in the calling sequence, it specifies the "alphabet" upon which the random string is generated. This option can assume one of two forms. If it is of type string, then the characters in that string are taken to be the alphabet from which to randomly draw characters in the output string. The alphabet characters must appear in US-ASCII order and cannot contain repetitions.
 If the alphabet parameter is a symbol, then it must be one of the following recognized character class names.

 Symbol Range of Characters alpha A-Z or a-z ascii ASCII code 1 through 127 alnum A-Z, a-z, or 0-9 binary 0 or 1 cntrl FF, NL, CR, HT, VT, BEL, or BS digit 0-9 dna A,C,G or T graph alnum or punct xdigit 0-9, a-f, or A-F ident A-Z, a-z, 0-9, or _ ident1 A-Z, a-z, or _ lower a-z octal 0-7 print punct, alnum, or space character (" ") punct ascii and not in alnum, space, or cntrl space tab ("\t"), newline ("\n"), vertical tab ("\v") form-feed ("\f"), or space (" ") upper A-Z

 • The Randomize command, which takes an optional integer seed argument, is used to initialize the random number generator.  This command is now just an alias for the top-level randomize command.
 • 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{length}\left(\mathrm{Random}\left(100000\right)\right)$
 ${100000}$ (1)
 > $\mathrm{length}\left(\mathrm{Select}\left(\mathrm{IsAlphaNumeric},\mathrm{Random}\left(100000\right)\right)\right)$
 ${24412}$ (2)
 > $\left(\mathrm{min},\mathrm{max}\right)\left(\mathrm{op}\left(\mathrm{convert}\left(\mathrm{Random}\left(100000\right),'\mathrm{bytes}'\right)\right)\right)$
 ${1}{,}{255}$ (3)
 > $\mathrm{dna}≔\mathrm{Random}\left(20,"ACGT"\right)$
 ${\mathrm{dna}}{≔}{"CAGGAAGTTTCTCCTATGTC"}$ (4)
 > $\mathrm{Random}\left(20,'\mathrm{binary}'\right)$
 ${"11000100001000110101"}$ (5)
 > $\mathrm{Random}\left(20,'\mathrm{upper}'\right)$
 ${"FUWAOGIXUXHQIFZXZUQA"}$ (6)
 > $\mathrm{IsDigit}\left(\mathrm{Random}\left(1000,'\mathrm{digit}'\right)\right)$
 ${\mathrm{true}}$ (7)