StringTools
NthWord
generate the nth word on a given alphabet
Calling Sequence
Parameters
Description
Examples
NthWord( alphabet, n )
alphabet
-
string; alphabet to use
n
non-negative integer; nth word to generate
The NthWord(alphabet, n) command generates the nth word on the given ordered alphabet, which consists of the characters in the string alphabet. The string alphabet must not contain repeated characters. Words are enumerated in shortlex order.
The 0th word on any alphabet is the empty string .
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.
with⁡StringTools:
seq⁡NthWord⁡abc,i,i=1..20
a,b,c,aa,ab,ac,ba,bb,bc,ca,cb,cc,aaa,aab,aac,aba,abb,abc,aca,acb
seq⁡NthWord⁡abcde,i,i=1..20
a,b,c,d,e,aa,ab,ac,ad,ae,ba,bb,bc,bd,be,ca,cb,cc,cd,ce
NthWord⁡abc,231−1
abaababbbaacccacacca
NthWord⁡abc,5
ab
NthWord⁡bca,5
bc
See Also
length
StringTools[Fill]
StringTools[Generate]
Download Help Document