esolang

Prelude

Every line is a voice with its own stack, and all voices play the same column at the same time.

Nikita Ayzikovsky, 2005 · Turing complete: yes · ●●○ moderate · esolangs.org

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

Run it

Expected: Hello, World!

The idea

Nikita Ayzikovsky made Prelude in 2005 as the ASCII form of Fugue, a language written as polyphonic music. A program is a score. Each line of text is one voice, and the program runs left to right one column at a time. In every column each voice does its own instruction, all at once.

Read the story

Voices talk by reading each other's stacks. ^ copies the top of the voice above and v the top of the voice below, as the stacks stood before the column. Loops are brackets, and a bracket belongs to the whole score, not to one line.

The machine

One stack of unbounded integers per voice, with endless zeros underneath.

CommandDoes
0–9Push a digit
+ -Add; subtract the top from the one below
#Pop
^ vPush the top of the voice above, or below
(If the top is 0, skip past the matching )
)If the top is not 0, go back past the matching (
?Read a character; 0 at the end of the input
!Pop and write it as a character

Brackets match by column, and only one voice may hold a bracket in any column. There is no way to duplicate a value except ^ in a program of one voice, which reads its own stack.

Example

Hello World keeps one digit per letter.
Expected: cat me
Expected: FFFFF
Expected: H

Hello World keeps one digit per letter. With a single voice, ^ copies its own top, so ^+^+^^+++ turns the top digit d into 12d plus the digit below, so 6 gives 72, H, then 8 and 5 give 101, e. The last program has two voices. The lower one copies the 9 from the upper one and adds seven more 9s.

Further

Ideas it shows

Stack-based

Write your own in Run Convert a program from Prelude

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run prelude -e '?(!?)' --input 'cat me'
shib manual prelude

Source

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

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

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