apiculture/alphabet

Types

An alphabet is a character repertoire used for direct sampling. This is distinct from an encoding, which transforms bytes to text.

pub type Alphabet {
  Alphabet(chars: String)
}

Constructors

  • Alphabet(chars: String)

Values

pub fn characters(alphabet: Alphabet) -> List(String)

Returns the characters in the alphabet as a list of graphemes.

pub fn new_alphabet(
  chars: String,
) -> Result(Alphabet, error.Error)

Creates a new alphabet from a string of characters.

Returns an error if the alphabet is empty, has only one character, or contains duplicate characters.

pub fn size(alphabet: Alphabet) -> Int

Returns the size (number of characters) in the alphabet.

Search Document