esolang

Nix

Befunge squeezed onto one line. The pointer runs left or right, and the line wraps around.

Quiqucode · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello, World!

The idea

Quiqucode made Nix to sit between languages read left to right and directional ones like Befunge and

Read the story
<>. The instruction pointer starts on the first character of the first line, going right. It can turn

round but never step to another line, and when it runs off one end it comes back in at the other.

Other lines are methods. | pops a number and runs that line, counting from 0, from its first character going right, and then the pointer carries on where it was. Every character is one command, so the author hopes Nix will do for code golf.

The machine

One stack of whole numbers.

CommandDoes
0 to 9Push the digit
+ - * / %Pop two and push the result
: $ fDuplicate, drop, swap
r [ ]Reverse the stack; move the bottom item to the top, or the top to the bottom
'...'Push the code of every character in between
< >Go left or right
~Pop, and turn round if it is not 0
@ #Skip the next command; pop and skip it if 0
( )Jump to the partner
\|Pop k and run line k as a method
o nPrint a character or a number
i sRead a number, or push the code of every character of a line
gPop n and push the code of character n of the line
xEnd the line

The specification's list of commands leaves out x, but every example ends with one, and without it the quine would print a quote mark again on every lap. x ends the program on the first line and returns from a method on any other.

Example

The usual way to print is to push the text, then a 0, and reverse the stack, so the first letter is on…

The usual way to print is to push the text, then a 0, and reverse the stack, so the first letter is on top and the 0 at the bottom. The loop >:@o~ then goes right to test the top and left to print it. @ skips the o on the way out and the : on the way back, so each lap prints one character, until the 0 lets the pointer through to x.

Expected: cat

The quine. The opening quote mark captures the whole line, because the pointer wraps round to it again. 94*3+ makes 39, the code of the quote mark itself.

Expected: '0r94*3+>:@o~x

Patterns it teaches

Further

Two-dimensional languages

Stack-based

Write your own in Run Convert a program from Nix

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: nix.

Command line

shib run nix -e 's0r>:@o~x' --input 'cat'
shib manual nix

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/nix.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org