Tir
A golfing language with a lot of symbols.
Conor O'Brien · Turing complete: unknown · ●●○ moderate
Tested with 9 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
Tir is a golfing language by Conor O'Brien, written in D, with its own code page of symbols. It is a stack language over big integers, strings and arrays, and whatever is left on the stack is printed at the end, one item per line.
Read the story
Its strings have an odd rule. If a ⦀ comes anywhere further on in the program, everything up to it is one string. So Hello, World!⦀ needs no opening quote at all. Another rule is just as odd. A token whose first character names a variable pushes the variable, so A is the alphabet and N a newline, wherever they turn up.
The machine
| Command | Does |
|---|---|
12, «text», text⦀, ①x | A number, a string, a string up to here, a quoted character |
+ - ÷ % | Add numbers or join strings, subtract, divide, remainder |
× | Adds as well, as the reference has it |
, & ∎ | Make a pair, join into an array, gather the whole stack |
↔ ι r @ o | Swap, 0 to n minus 1, a range, an index, a character code |
℘ = | The item written as code; equal, 1 or 0 |
⨞ ⟁ | Print and drop, print and keep |
i :x | Push the next argument; store the top in x |
An operator that finds too few values takes the next argument instead, or 0 when there are none. The full language also has functions in { } and about twenty meta operators that change what the next operator does. This implementation has the core above and stops with a reason on the rest.
Example
The last one pushes the variable A, the upper case alphabet, and o gives the code of its first letter.
The last one pushes the variable A, the upper case alphabet, and o gives the code of its first letter.
Patterns it teaches
- Code golf: one symbol per operator, and strings that need only a closing mark.
- Stack machines: the program's result is simply what is left on the stack.
Try this
- Print the difference of 100 and 58.
- Print the letter
RusingAand@. - Hard: print the sum of the character codes of
cat.
Further
See also
Also in Golfing
Write your own in Run Convert a program from Tir
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: tir.
Command line
shib run tir -e '5ι'shib manual tirSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/tir.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language