Skip to main content
Version: Sprint 4

setalpha

Defines the tape alphabet - the set of symbols that can appear on the tape.

Syntax​

setalpha(symbol1, symbol2, ...);

Parameters​

  • symbol1, symbol2, ...: One or more single-character symbols

Examples​

setalpha(0, 1);
setalpha(a, b, c, x, y, z);
setalpha(0, 1, #, _);

Rules​

  • Must declare at least one symbol
  • Can only be declared once
  • Symbols are case-sensitive (A ≠ a)
  • Symbols must be single characters
  • Cannot conflict with declared state names
  • No duplicate symbols allowed

Default Behavior​

If setalpha is not declared, the machine will use a default alphabet. However, it's recommended to always explicitly declare your alphabet.

Examples​

Valid:

setalpha(0, 1);
makestates(q0, q1);

Invalid - conflicts with state name:

setalpha(q0, 0, 1); ### ERROR: 'q0' conflicts with a declared state
makestates(q0, q1);

Invalid - duplicate symbol:

setalpha(0, 1, 0); ### ERROR: duplicate alphabet symbol '0'

Errors​

  • Empty alphabet: 'setalpha' requires at least one symbol
  • Duplicate declaration: duplicate 'setalpha' — a second alphabet declaration is not allowed
  • State conflict: 'X' conflicts with a declared state
  • Duplicate symbol: duplicate alphabet symbol 'X'

See Also​