li1I is a domain-specific programming language for integer calculations. It supports recursive functions, conditional execution, and expresses arithmetic in Reverse Polish notation.
It was designed by User:TartanLlama in 2017.
The only valid characters in an li1I program are
I and whitespace. There is no syntax for comments. Comments are not necessary in a language of such clarity.
Here's a function which computes the factorial of its argument:
li1I l1iI lI1i I li1l i lil1 l1i1 li1l i 11 ll11 l1ii lil1 11 l1ii l1il i 11 llii I i liil l1ii l1ii lI1i IIII liI1 i lIi1 11111111111 l1ii I l1ii l1Ii
An li1I program consists of the token
li1I followed by any number of functions enclosed in braces. Left brace is spelled
l1iI and right brace is spelled
l1Ii. Here is an empty program:
li1I l1iI l1Ii
Literals and Identifiers
Function identifiers are of the form
Variable identifiers are of the form
The only type supported in li1I is an integer. The author cannot remember what kind of integer it is. The value of an integer is given by the length of a string of
1s minus 1. E.g.
1 has the value 0,
11 has the value 1,
1111111111 has the value 9 and so on.
A function is indicated with the token
lI1i, which is followed by a function identifier, any number of variable identifiers (parameters), then a brace-enclosed block.
In that brace enclosed block, any number of statements are allowed.
A statement is an expression followed by the token
An expression can be:
- The name of a variable, which evaluates to its value.
- A variable declaration, spelled
liI1 <variable identifier> lIi1 <expression>, which evaluates to the value of the initialiser.
- A function call, spelled
<function identifier> li1l <expression>* lil1, which evaluates to the result of the function call.
- An arithmetic or logical expression (see below).
- A conditional expression (see below).
Arithmetic and logical expressions in li1I are written in Reverse Polish notation.
The following arithmetic operations and their spelling in `li1I` are:
- Integer division:
The following logical operations and their spelling in `li1I` are:
- Greater than:
- Less than:
A conditional expression is of the form:
l1i1 li1l <arithmetic or logical expression> lil1 l1iI <then statements>* l1Ii l1il l1iI <else statements>* l1Ii
Is a then with no else supported? Who knows.
An implementation which targets LLVM can be found on GitHub.