esolang

Fourier

One accumulator, and every operator takes its right side from the very next command.

Beta Decay, 2015 · 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

Beta Decay, a Code Golf Stack Exchange user, made Fourier in 2015 as a golfing language. Where brainfuck has a tape, Fourier has a single number, the accumulator, plus variables with one-character names. A digit run sets the accumulator, a prints it as a character and o as a number.

Read the story

Operators do not parse expressions. + remembers the accumulator, runs exactly one more command, and adds what that command left behind. So +5 adds five and +x adds the variable x.

The machine

CommandDoes
12 ^ vSet to 12; add 1; take 1
a o `text` Print as a character; print as a number; print the text
~x xStore in variable x; load x, 0 if it is new
+ - * / % PCombine with the next command; / rounds down, P is a power
< > =1 or 0 by comparing with the next command
( … )Set to 0, then repeat until the accumulator equals what it was before (
{a}{b}Run b only if a gives the accumulator; these do not nest
I L @Read a line as a number; the whole part of log10; clear the output

The Python interpreter keeps all output in a string and prints it once, when the program runs off the end. That is why @ can clear it. Integers have no size limit, and a literal with a dot is a float.

Example

The second program sets the accumulator to 126 before (, so the loop runs until j reaches 126.
Expected: "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
Expected: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34
Expected: 3 2

The second program sets the accumulator to 126 before (, so the loop runs until j reaches 126. The third reads how many Fibonacci numbers to print. The last shows that / rounds down and that a remainder takes the sign of the divisor, as in Python.

Further

Ideas it shows

Golfing languages

Write your own in Run Convert a program from Fourier

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run fourier -e '33~j126(j^a~j)'
shib manual fourier

Source

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

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

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