esolang

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

Expected: 100

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

CodeDoes
x ← y or y → xPut the value of y into x
Α ΒRegisters that point at cells
α βThe cells they point at
7The 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.

Expected: 3628800

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.

Expected: 2 3 5 7 11 13 17 19 23 29

The Fibonacci prints 47 numbers, up to 1,836,311,903, and stops once the next one has wrapped below 0.

Patterns it teaches

Further

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 codan

Source

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