Quiner

From Esolang
Jump to navigation Jump to search

Quiner is a simple esoteric programming language focused on using quines as a method of looping and conditional execution. Created by User:Umnikos in 2020.

Concepts

There are two deques: one to store your program (the code deque), and another to store data (the data deque). When there is no more code in the code deque to be executed, the roles of the code deque and data deque switch, and the execution continues from the new code deque.

Each deque has its own instruction pointer that executes instructions sequentially. When data is appended to the end of the data deque, the data deque's instruction pointer does not move; it only starts moving when execution switches to it. Code does not disappear from either of the deques after getting executed, instead it can later be retrieved with the < instruction. Execution halts when both of the deques' instruction pointers have reached the end of their respective deques.

Instructions

In the following table, a means an optional decimal number before the actual instruction. If not included, a defaults to 1 (unless otherwise stated). If an instruction tries to act on a characters but there are less than that, it just acts on as many as there are.

a* Remove the last a characters from the end of the data deque. If the data queue's instruction pointer now points to nothing, move it back to the end of the data deque.
a, Input a characters from standard input and append them to the end of the data deque.
a. Remove the last a characters from the end of the data deque and print them to standard output.
a> Append the following a characters to the end of the data deque and skip their execution.
a< Append the previous a characters to the end of the data deque (not counting a as part of the characters).
a/? If ? is the / character, skip the execution of the next a characters (not counting / as part of the characters). Otherwise, do nothing (and do not execute the ? character).
a+ Remove the last a characters from the end of the data deque, add their ascii values together (overflowing at 256), and append the resulting sum as an ascii character to the data deque. The default value for a is 2.

Invalid instructions do nothing and are simply skipped over.

Examples

Hello, World!

Simple version:

13>Hello, World!13.

Stylish version: (also prints a newline at the end)

5>3+14.99//Hello, World!6X|

Infinite loop

One that cleans after itself:

4*4*4*4<4<4<

A shorter one that doesn't:

<<<

Cat program

,.99*014<4<4<

Truth machine

2>9/ ,4>@@@>5+ 99> 1>0.99// 1>1.004<4<4<

Quine

A short one that kind of cheats by just using the data deque to print the entire code queue:

2>4.

A longer one that never switches execution to the data deque:

8<8.8<8.8<8.

Other examples

Input a character and print it twice:

>>,9>#2<*2.99*

Input a character, add 1 to its ascii value, and print it:

,4>@@@A5+.*

Multi-line programs

There is nothing in the specification saying that a Quiner program must only span one line, but if the specific interpeter does not support more than a single line of code, it's still possible to have the first line of code input the rest of the program onto the data deque and then immediately switch execution to it.

Example with hello world:

$ python3 interpreter.py
enter quiner code: 30,
13>Hello, world!
4>@@@J4+
14.
Hello, world!

Interpreters