esolang

Schwa

Three letters, two states, six commands. What a letter does depends on what came before it.

ChuckEsoteric08 · Turing complete: no · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hello, World!

The idea

ChuckEsoteric08 made Schwa, named after the vowel ə, after ABCDXYZ. The machine has one variable, the input, and is always in state 1 or state 2. The same three letters mean different things in each state, and two of the six meanings only switch the state. So a program reads like a code where every letter has to be decoded by the letters before it.

Read the story

The letter ə is also data. A loop ends when the input is ə.

The machine

LetterState 1State 2
aChange to state 2Read a line into the input
əPrint the inputChange to state 1
eStart a loop, unless the input is əGo back to the loop's start, unless the input is ə

The input starts empty, and every other character is ignored. The state belongs to the run, so when a loop goes back its letters may mean something else the second time. The cat needs that. Its first ə prints the empty input once, and on every later pass it only switches the state. The compilation to FakeScript fixes each letter's state by its place instead, and there the cat prints every line but the last twice.

Example

The Text interpreter reads one line and prints it.

The Text interpreter reads one line and prints it.

The cat prints each line it reads, until a line that is ə. Lines are printed as they are, with no line break after them.

Expected: catə

The truth machine aaəəeəəe prints its input and then reaches two e in state 1, so both start a loop and none ends one. On ə it prints ə once; on anything else it prints it three times and stops.

Further

Also in Turing tarpits

Write your own in Run Convert a program from Schwa

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run schwa -e 'aaəə' --input 'Hello, World!'
shib manual schwa

Source

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

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

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