esolang

Premier

The code runs once for every character of the data. To loop, add data; to branch, rewrite the code.

Conor O'Brien · Turing complete: unknown · ●●○ moderate

Tested with 7 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Hello, World!

The idea

A Premier program has two parts. The first line is the code and everything after it is the data. The code runs once per character of the data, with that character pushed on the stack, and at the end of each round the top of the stack is printed. So a program whose first line is empty prints its data back: the Hello World on Try It Online is a blank line and then Hello, World!.

Read the story

There are no loops or jumps. A program loops by adding to its own data, which gives it more rounds, and changes what it does by putting text before or after its own code, which takes effect in the next round.

The machine

CodeDoes
12 'x `x "…" […] | Push a number, a character, its code, a string
+ - * / %Arithmetic, or join, repeat and format strings; failure gives 0
= ~1 or 0 for equal, not equal
@ : \ r C b dDrop, duplicate, swap, reverse, clear, rotate n, duplicate n
_ c o s l f LNegate or reverse, to character, to code, next, length, first n, all but n
n O p IPrint, print with a newline, print as a character, no output this round
i < > Q $ A ^Data position and moving it, push, replace or add to the data
P T a v #Push the code, put text before or after it, replace it
g G SRead a line onto the stack, a line or everything into the data
eExit

A first line that starts with a number N takes N more lines as code. The reference is premier.rb in github.com/ConorOBrien-Foxx/Premier. This implementation leaves out |…|, which runs code over each character, and the two commands that wait for a key press.

Example

The second shifts each letter of HAL one place up the alphabet.
Expected: IBM
Expected: h i
Expected: Hi, Ada
Expected: 0

The second shifts each letter of HAL one place up the alphabet. The third turns off the implicit output and prints each character with a newline instead. The last shows the rule about numbers. The first line starts with 3, so 3 is not code: the code is 4*n10c, and 4* has nothing to multiply.

Patterns it teaches

Further

Also in Strange time

Write your own in Run Convert a program from Premier

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run premier -e 'I
abc'
shib manual premier

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/premier.js

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