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
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" the numbers in the registers must be interpreted as letters. It can achieved by defining a simple alphabet:

Letter Value
1
d 2
e 3
H 4
l 5
o 6
r 7
W 8

The following program sets A progressively to 4, 3, 5, 5, 6, 1, 8, 6, 7, 5, 2 which corresponds to "Hello World":

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

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