Colon period period colon

From Esolang
Jump to navigation Jump to search
The title of this article is not correct because of technical limitations. The correct title is actually :..:.
:..:
Paradigm(s) imperative
Designed by User:Ttulka
Appeared in 2024
Memory system Cell-based
Dimensions one-dimensional
Computational class Turing complete
Major implementations Interpreter in JavaScript
File extension(s) .cppc

:..: is an esoteric programming language based on the manipulation of four unbounded integer registers.

How it works

A program in :..:

  • Consists only of the symbols : (colon) and . (period); all other symbols are ignored.
  • Is a sequence of 4-tuples that form program instructions (the program length % 4 == 0).
  • Has a length greater than zero (at least one 4-tuple).

Each 4-tuple reads or manipulates one of the four registers A, B, C, D.

The current register is determined by the index of the instruction in the program code. For instance, the first instruction works with A, fourth with D, fifth with A, and so on.

Four possible instructions can be formed based on the position of the colon in a 4-tuple:

Instruction Name Meaning Code
Noop Does nothing ....
+ Increment Increments the current register value .:..
- Decrement Decrements the current register value ..:.
[ Loop begin Jumps to the loop end if the current register value is not zero :...
] Loop end Jumps to the paring [ ...:

Instructions [ and ] are paired, meaning each [ must have a following ] and vice versa.

Instructions can be combined into compact ones. For instance, the 4-tuple ::.. contains both instructions [ (loop begin) and + (increment). Compact instructions are executed in the order they appear in the 4-tuple.

Examples

(Code is arbitrarily wrapped at a maximum of one hundred characters per line.)

No-op program

Does nothing:

....

Infinite loop

Loops forever:

:..:

Clear

Sets register A to zero:

........:.......:........:.......:.:..............::......:.....

Move

Moves register B to register A:

........:...........:....:...........:.:.........:....:....:......:...:...:.....

Copy

Copies register A to register B:

........:.......:........:.......:.:..............:..:.......:.:......:...:...:.........:...:.......
.....:...:.:..............:..:.:..............:.......:.....

Switch

Switches register A with register B:

........:.......::.......:.:.:....::......:...:.........:...........::...:.:.....:....::..:.......:.
....:...::...........:.:..:......:.:..:...........:.........

Fibonacci sequence

Computes the sequence in register A:

.....:..:...............:.......::.......:.:.:....::......:...:.........:...........::...:.:.....:..
..::..:.......:.....:...::...........:.:..:......:.:..:...........:.:.......::.......:.:.:....:..:.:
..:...:.......:.:...::...........:.:..:..:.:......:.......::............

Hello World

For computing "Hello World" we need to interpret integers in registers as a string. We can achieve this by defining an alphabet and concatenating register values.

d e H l o r W
000 001 010 011 100 101 110 111

Registers must contain the following values:

Register Binary Decimal Interpreted
A 011010100 212 Hel
B 100101000 296 lo⎵
C 111101110 494 Wor
D 100001 33 ld
.:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:..
.:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:..
.:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:..
.:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:..
.:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:..
.:...:...:...:...:...:...:...:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:..
.:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:..
.....:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:......
.:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:..
.:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:..
.:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:..
.....:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:......
.:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:..
.:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:..
.:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:..
.....:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:......
.:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:..
.:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:..
.:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:..
.....:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:......
.:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:..
.:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:..
.:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:..
.....:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:......
.:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:..
.:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:..
.:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:..
.....:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:......
.:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:..
.:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:..
.:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:..
.....:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:......
.:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:..
.:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:.......:...:...:...........:..
.:...........:...:...........:...:...........:...:...........:...:...........:...:...........:...:..
.........:...:...........:...:...........:...:...........:...:...........:...:...........:...:......
.....:...:...........:...:...........:...:...........:...:...........:...:...........:...:..........
.:...:...........:...:...........:...:...........:...:...........:...:...........:...:...........:..
.:...........:...:...........:...:...........:...:...........:...:...........:...:...........:...:..
.........:...:...........:...:...........:...:...........:...:...........:...:...........:...:......
.....:...:...........:...:...........:...:...........:...:...........:...:...........:...:..........
.:...:...........:...:...........:...:...........:...:...........:...:...........:...:...........:..
.:...........:...:...........:...:...........:...:...........:...:...........:...:...........:...:..
.........:...:...........:...:...........:...:...........:...:...........:...:...........:...:......
.....:...:...........:...:...........:...:...........:...:...........:...:...........:...:..........
.:...:...........:...:...........:...:...........:...:...........:...:...........:...:...........:..
.:...........:...:...........:...:...........:...:...........:...:...........:...:...........:...:..
.........:...:...........:...:...............:...............:...............:...............:......
.........:...............:...............:...............:...............:...............:..........
.....:...............:...............:...............:...............:...............:..............
.:...............:...............:...............:...............:...............:...............:..
.............:...............:...............:...............:...............:...............:......
.........:...............:...............:...............:...............:...............:..........
.....:...............:...............:...............:...............:...............:..............
.:...............:...............:...............:...............:...............:...............:..
.............:...............:...............:...............:...............:...............:......
.........:...............:...............:...............:...............:...............:..........
.....:...............:...............:...............:...............:...............:..............
.:...............:...............:...............:...............:...............:...............:..
.............:...............:...............:...............:...............:...............:......
.........:...............:...............:...............:...............:...............:..........
.....:...............:...............:...............:...............:...............:..............
.:...............:...............:...............:...............:...............:...............:..
.............:...............:...............:...............:...............:...............:......
.........:...............:...............:...............:...............:...............:..........
.....:...............:...............:...............:...............:...............:..............
.:...............:...............:...............:...............:...............:...............:..
.............:...............:...............:...............:...............:...............:......
.........:...............:...............:...............:...............:...............:..........
.....:...............:...............:...............:...............:...............:..............
.:...............:...............:...............:...............:...............:...............:..
.............:...............:...............:...............:...............:...............:......
.........:...............:...............:...............:...............:...............:..........
.....:...............:...............:...............:...............:...............:..............
.:...............:...............:...............:...............:...............:...............:..
.............:...............:...............:...............:...............:...............:......
.........:...............:...............:...............:...............:...............:..........
.....:...............:...............:...............:...............:...............:..............
.:...............:...............:...............:...............:...............:...............:..
....

Turing completeness

To demonstrate that :..: is Turing-complete, we can utilize the structured program theorem, which asserts that sequence, selection, and repetition are adequate constructs to construct any computer program.

We can translate any register machine with two registers (simulated by A and B), as register machines with just two registers were proven to be Turing equivalent.

Full proof can be found in the external resources.

External resources