[ EN | FR ]
Thue is an esoteric language invented by John Colagiola in 2000. The Thue web pages tend to grow scarce these days, so I've included copies of material initially found on the web before it disappeared.
Here is a short description of the language. Refer to the Thue reference manual in the original distribution for more details.
A Thue program consists of two parts: the rule base and the initial data. The rule base is a list of rules expressed in the form:
where the left hand side (LHS) and right hand side (RHS) are strings of characters. The line
separates the rule base from the initial data; The initial data is the string of characters resulting from the concatenation of all subsequent lines, omitting the <newline> characters.
Thue works by repeatedly picking at random a rule whose LHS string is contained in the current data, and replacing the LHS by the RHS. The program stops when no rule can match.
Input/output is allowed by the following primitives:
The Thue reference manual is not very clear about newlines in input/output. Existing Thue interpreters tend to output a newline after each output rule is triggered. However this prevents writing Thue programs which need a finer control on the output (like self-reproducing programs that output exactly their own code).
I propose a variant of Thue where:
With this convention, nice programs like quines and 99 bottles of beer can be written.
All programs below assume the output variant described above.
(C) 2003 - Laurent VOGEL|