Learn THUE with Real Code Examples
Updated Nov 26, 2025
Code Sample Descriptions
1
Hello World in Thue
::=
::=Hello World!
::=::
A simple Thue program that outputs 'Hello World!'. The rules transform an initial start symbol into the target string.
2
Simple Increment
N::=0
N::=N1
N::=N2
N::=N3
N::=N4
N::=N5
N::=N6
N::=N7
N::=N8
N::=N9
Increment a number represented as a string of digits.
3
Simple Decrement
D1::=0
D2::=1
D3::=2
D4::=3
D5::=4
D6::=5
D7::=6
D8::=7
D9::=8
D0::=9
Decrement a number represented as a string of digits.
4
Print Numbers 1 to 3
S::=1A
A::=2B
B::=3
C::=::
S
Prints numbers 1, 2, 3 sequentially using Thue rules.
7
Conditional Output Example
S::=A?YES:NO
A::=::
S
Outputs 'YES' if symbol A exists, 'NO' otherwise.
8
Palindrome Check
S::=ABA
ABA::=PALINDROME
B::=::
S
Checks if a string is a palindrome using Thue transformations.
10
Factorial Concept
F::=1
F::=F*2
F::=F*3
F::=F*4
F::=RESULT
RESULT::=::
F
A simple conceptual Thue program to illustrate factorial transformation.