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
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
| Command | Does |
|---|---|
12 ^ v | Set to 12; add 1; take 1 |
a o `text` | Print as a character; print as a number; print the text |
~x x | Store in variable x; load x, 0 if it is new |
+ - * / % P | Combine 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.
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
- esolangs.org/wiki/Fourier
- The reference interpreters, in Python and JavaScript
Ideas it shows
See also
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 fourierSource
- 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