Rhotor is a lazy evaluating functional programming language that utilizes pattern matching.
Rhotor has 3 data types:
- Functions have a matching pattern (the function head), the function code (the function body) and an optional failure function (the function footer)
- Nil is the only constant in Rhotor.
- A cons concatenates two other items. It can be used to build lists or tree structures. As there are no numbers or strings in Rhotor you have to use Cons and Nil to represent them.
Operators with the highest precedence are listed first.
- Those signs act as parentheses. Empty parentheses evaluate to Nil.
- This syntax is used for functions. Functions are right associative. (
a/b/cis the same as
a/<b/c>). Wrap functions that use the Footer in parentheses.
- This is the syntax for concatenation (Cons). Concatenation is right associative.
- This is the syntax for application. It applies function to argument. Application is left associative.
- A lowercase word acts as a symbol. Symbols can be defined in a function head and are valid in the body. If you want to redefine a symbol you have to use the
- This redefines a symbol and can only be used in a function head.
Spaces, uppercase letters and periods are equivalent and can be used to separate symbols and comment the code.
A pattern is build using Nil, cons and symbols. A pattern matches a function if all elements, except symbols, are equal. Symbols act as a wildcard and match anything.
Nil argumentalways evaluates to Nil.
a,b argumentevaluates to
<a argument>,<b argument>.
function matching-argumentevaluates to the body of the function where every symbol in the body is replaced with the value the same symbol in the pattern matched. Symbols that doesn't occur in the pattern aren't replaced.
footerless-function non-matching-argumentevaluates to Nil.
function non-matching-argumentevaluates to
Rhotor specifies data representations for natural numbers and strings. They are not part of the language but of the IO system.
Numbers are written as
<> followed by N times
,<>. There is a short cut notation
Strings are written as
<byte1>,<byte2>...<byteN>. Again, there is a short cut notation
%"String". You may use
\n for a newline and
\" for a quote character.
The program is applied to the user input and the evaluated string is printed to the screen.
Turing completeness proof
Using the following rules, it is possible to transform any lambda calculus expression into an equivalent Rhotor expression.
- Replace every ( and ) with
- Replace every λ a . b with
- First working Rhotor interpreter written in Haskell. (from the Wayback Machine; retrieved on 8 December 2006)
- Alternative link from the Esoteric File Archive.