The ToString class
Class for converting list[int] to strings with specified alphabet.
An instance of this class is callable and used to convert from list[int] to
str. The integers in the list are converted to characters according to
their position in the alphabet used to construct a ToString instance if
one is provided, or using words.human_readable_letter otherwise.
>>> from libsemigroups_pybind11 import ToString
>>> to_string = ToString("bac")
>>> to_string([0, 1, 2])
'bac'
>>> to_string([0, 1, 0, 1, 0, 0, 0, 2, 0, 2])
'bababbbcbc'
>>> to_string.init()      # clear the alphabet
<ToString object with alphabet "">
>>> to_string([0, 1, 2])
'abc'
Contents
| Class for converting  | |
| Return the alphabet used for conversion. | |
| Check if the current ToString instance can convert a specified letter. | |
| Copy a  | |
| Check if the alphabet is defined. | |
| Overloaded function. | 
Full API
- class ToString
- __init__(*args, **kwargs)
- Overloaded function. 
 - __call__(self: ToString, input: list[int]) str
- Convert a - list[int]to a- str.- This function converts its argument input into a - str. The characters of input are converted using the alphabet used to construct the object or set via- init(), or with- words.human_readable_letterif- empty()returns- True.- Parameters:
- Returns:
- The converted string. 
- Return type:
- Raises:
- LibsemigroupsError – if the alphabet used to define an instance of - ToStringis not empty and input contains letters that do not correspond to letters of the alphabet.
 
 - alphabet(self: ToString) str
- Return the alphabet used for conversion. - This function returns a - strcorresponding to the ordered-set alphabet \(\{a_0, a_1, \dots, a_{n-1}\}\) that the initialised- ToStringobject will use to convert from- list[int]to- str. Specifically, \(i \mapsto a_i\) where \(i\) will be an- intin a list and \(a_i\) will be a character in a- str.- If this function returns the empty string, then conversion will be performed using - words.human_readable_letter.- Returns:
- The alphabet. 
- Return type:
 
 - can_convert_letter(self: ToString, l: int) bool
- Check if the current ToString instance can convert a specified letter. - This function returns - Trueif l can be converted to a- strusing this ToString instance, and- Falseotherwise.
 - empty(self: ToString) bool
- Check if the alphabet is defined. - This function return - Trueif no alphabet has been defined, and- Falseotherwise.- Returns:
- A whether the alphabet is empty. 
- Return type:
 
 - init(*args, **kwargs)
- Overloaded function. - init(self: ToString) ToString
- Initialize an existing ToString object. - This function puts a - ToStringobject back into the same state as if it had been newly default constructed.- Returns:
- self. 
- Return type:
 - See also 
 - init(self: ToString, alphabet: str) ToString
- Initialize an existing Tostring object. - This function puts a - ToStringobject back into the same state as if it had been newly constructed from alphabet.- Parameters:
- alphabet (str) – the alphabet. 
- Returns:
- self. 
- Return type:
- Raises:
- LibsemigroupsError – if there are repeated letters in alphabet. 
 - See also