Counterlang
Named counters, a goto by line number, and no way to ask a question.
2024 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Counterlang, from 2024, keeps its data in named counters. A line can add to a counter, take from it or reset it, print a number or a character, or jump to another line. That is all. There is no if, so a loop that should end has to jump to a line number that it keeps in a counter.
The machine
| Line | Does |
|---|---|
count a | Make the counter a, at 0 |
a5 ab | Add 5, or add the counter b; aa doubles a |
a-5 a- | Take 5 away; reset to 0 |
.5 ,65 | Print 5 as a number; print the character 65, A |
!3 !a | Go to line 3, or to the line a holds |
: | End the program |
A # starts a comment. Lines count from 1. Running past the last line also ends the program.
Example
The two print lines.
The two print lines.
The counter lines add 1, take 2 and add 2, then double three times. That leaves a at 8, though the comment says 16.
A loop that stops. The counter t starts at 7 and grows by 1 on every pass, so !t lands one line further down a table each time. Two entries jump back to the loop and the third ends the program.
The specification's own loop counts up from 0 and never stops.
Patterns it teaches
- Counter machines: counters and jumps, but with no test for 0.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from Counterlang
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: counterlang.
Command line
shib run counterlang -e '.1 #prints 1
,65 #prints A'shib manual counterlangSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/counterlang.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org