Codan
Brainfuck's row of cells behind two Greek pointers, moved with arrows. Almost no symbol is ASCII.
2010 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Codan was made in 2010 for a challenge on the /prog/ board. Its page says it was designed to annoy people who cannot type Unicode. The registers are Greek capitals, values move along arrows, and the comparisons include ≮ and ≰.
Read the story
Memory is a row of cells, as in brainfuck. The registers Α and Β point at cells, and α and β are the cells they point at. The arithmetic always works on α and β. A third register, Λ, is the terminal. Reading it reads a number, and writing it prints one.
There is one loop, « ... », and it never ends by itself. Assertions inside it end it, so α ≠ 100 keeps the loop going only while α is not 100.
The machine
| Code | Does |
|---|---|
x ← y or y → x | Put the value of y into x |
Α Β | Registers that point at cells |
α β | The cells they point at |
7 | The number 7 as a value, cell 7 as a target |
Λ | Read a number; as a target, print one |
+ − × ÷ ↑ | α and β added, subtracted, multiplied, divided, raised |
« ... » | Loop for ever |
x = y and ≠ < ≤ > ≥ ≮ ≯ ≰ ≱ | Inside a loop, end it unless this holds |
Values are 32-bit signed integers that wrap, as the Fibonacci expects, and Λ prints each number on its own line. The specification shows how each brainfuck command becomes a few Codan moves, which makes Codan Turing complete.
Example
The first example reads a number and adds β, which is 1, until it reaches 100.
The first example reads a number and adds β, which is 1, until it reaches 100. All whitespace is optional.
The factorial keeps n in cell 1, the product in cell 2 and a 1 in cell 3, and moves Β between the last two.
The sieve of Eratosthenes prints the 168 primes below 1000. This version uses 30 in place of 1000. Α walks up the numbers, an inner loop uses 0 = 1 as a plain break, and cell 0 holds Β while Β moves on by the prime.
The Fibonacci prints 47 numbers, up to 1,836,311,903, and stops once the next one has wrapped below 0.
Patterns it teaches
- Turing completeness: by translating brainfuck command for command.
Further
See also
Also in Hostile
Write your own in Run Convert a program from Codan
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: codan.
Command line
shib run codan -e '1 ← Λ
1 → 2
1 → 3
Α ← 1
Β ← 2
«
α ≰ 0
× → 2
Β ← 3
− → α
Β ← 2
»
β → Λ' --input '5'shib manual codanSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/codan.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org