StringTools[GenerateIdentifier] - create an identifier sequence generator
|
Calling Sequence
|
|
GenerateIdentifier( opts )
|
|
Parameters
|
|
opts
|
-
|
(optional) options
|
|
|
|
|
Description
|
|
•
|
The GenerateIdentifier command returns a procedure that, when invoked repeatedly, returns strings for use as identifiers.
|
•
|
Identifiers are, by default, formed by using the string as a base, and appending integer suffices until the length of the resulting string exceeds a specified maximum length.
|
•
|
The default maximum length is .
|
•
|
The maximum length can be changed by specifying the maxlen = LEN option, which takes a positive integer value LEN.
|
•
|
The default base string can be changed by specifying the base = STRING option.
|
•
|
In this case, the value of STRING will be used instead of .
|
•
|
The value of the base string must not exceed the maximum identifier length.
|
•
|
An alternative system of generating names can be invoked by using the option.
|
•
|
In this form, the returned generator forms strings by using maximal prefices of the given string, replacing suffices up to the maximum identifier length with digit sequences on subsequent calls.
|
•
|
The maximal prefix of the STRING used is shortened as long as at least one character from the string remains.
|
•
|
When no more unique strings not exceeding the maximum length can be generated, the returned generator raises the exception "no more identifiers".
|
|
|
Examples
|
|
>
|
|
>
|
|
>
|
|
| (1) |
>
|
|
>
|
|
>
|
|
| (2) |
>
|
|
>
|
|
>
|
|
| (3) |
>
|
|
| (4) |
>
|
|
>
|
|
>
|
|
| (5) |
>
|
|
>
|
|
| (6) |
>
|
|
|
|
Download Help Document
Was this information helpful?