Rhotor
Rhotor is an esoteric programming language developed by Jannis Harder in 2006.
Rhotor is a lazy evaluating functional programming language that utilizes pattern matching.
Data types
Rhotor has 3 data types:
- Functions
- Functions have a matching pattern (the function head), the function code (the function body) and an optional failure function (the function footer)
- Nil
- Nil is the only constant in Rhotor.
- Cons
- 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.
Language syntax
Operators with the highest precedence are listed first.
< >
- Those signs act as parentheses. Empty parentheses evaluate to Nil.
head/body
orhead/body\footer
- This syntax is used for functions. Functions are right associative. (
a/b/c
is the same asa/<b/c>
). Wrap functions that use the Footer in parentheses. car,cdr
- This is the syntax for concatenation (Cons). Concatenation is right associative.
function argument
orfunction.argument
- This is the syntax for application. It applies function to argument. Application is left associative.
lowercase word
- 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
:symbol
notation. :lowercase word
- 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.
Pattern matching
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.
Application rules
Nil argument
always evaluates to Nil.a,b argument
evaluates to<a argument>,<b argument>
.function matching-argument
evaluates 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-argument
evaluates to Nil.function non-matching-argument
evaluates tofunction-footer argument
.
Data representation
Rhotor specifies data representations for natural numbers and strings. They are not part of the language but of the IO system.
Numbers
Numbers are written as <>
followed by N times ,<>
. There is a short cut notation %N
.
Strings
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.
IO system
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
<
and>
. - Replace every λ a . b with
:a/b
External resources
- First working Rhotor interpreter written in Haskell. (from the Wayback Machine; retrieved on 8 December 2006)
- Alternative link from the Esoteric File Archive.