generate all strings of a given length on some alphabet - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Constructors : StringTools/Generate

StringTools[Generate] - generate all strings of a given length on some alphabet

Calling Sequence

Generate( len, supp )

Parameters

len

-

non-negative integer; length of the strings to generate

supp

-

string; support string specifying the alphabet to use

Description

• 

The Generate(len, supp) command generates a list consisting of all strings whose length is equal to len formed from the characters in the alphabet specified by the string supp. The string supp specifies the alphabet consisting of its distinct characters.

• 

Note that the number length( supp )^len of strings generated grows exponentially. Thus, it is usually practical to specify modest size arguments when calling this procedure. In particular, if the alphabet has at least two characters, then the maximum value for the len parameter is 25.

Examples

withStringTools:

Generate2,ab

aa,ab,ba,bb

(1)

Generate2,ababababa

aa,ab,ba,bb

(2)

Generate3,ab

aaa,aab,aba,abb,baa,bab,bba,bbb

(3)

Generate2,xyz

xx,xy,xz,yx,yy,yz,zx,zy,zz

(4)

numelemsGenerate10,abc

59049

(5)

This is not possible.

Generate100,abcde

Error, (in StringTools:-Generate) there are too many strings of length 100 on an alphabet of 5 characters

See Also

length, StringTools, StringTools[Fill]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam