Flurry
Brain-Flak's brackets, but the stack holds functions and side by side means apply.
Challenger5, 2019 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 9 known programs · Test method
Run it
The idea
Challenger5 made Flurry in 2019, after Brain-Flak. It keeps the four kinds of brackets and the stack. But the stack holds only functions, and two things side by side are not added, one is applied to the other. There are no numbers. A number is a Church numeral, a function that applies another function n times.
Read the story
() is the K combinator and <> is S, and [...] applies. That is enough to write any SK term, so the specification says Flurry is Turing complete even without its stack.
The machine
| Code | Gives |
|---|---|
() <> | K and S |
[] | The height of the stack, as a Church numeral |
{} | A value popped off the stack, or I when it is empty |
[abc] | a applied to b, and that to c |
(abc) | The same, and it is pushed too |
<abc> | a after b after c |
{abc} | A function that pushes its argument, then gives [abc] |
The specification leaves input and output open. In this implementation the numbers of the input are pushed as Church numerals, the first at the bottom, and the value of the whole program is printed as a number.
Example
The literal 2 pushes its argument, pops it twice and composes the two copies.
The literal 2 pushes its argument, pops it twice and composes the two copies. So it applies a function twice.
Sum, product and power of the two numbers on the stack. With n on top and m under it, {}{} applies n to m, which is m to the power n.
Bubbler's swap from the specification pops both numbers and pushes them back the other way round. Its own value is S K. Applied to () that becomes S K K, the identity, which lets the power through. Now it is 3 to the 2.
Patterns it teaches
- Combinators: S and K are two of the four nilads.
- Lambda encoding: numbers are Church numerals, and arithmetic is composition and application.
- Stack machines: a stack of functions, which
{abc}uses to hold its argument.
Further
- esolangs.org/wiki/Flurry
- Iota and Unlambda, other languages built on combinators.
See also
Functional paradigm
Stack-based
Write your own in Run Convert a program from Flurry
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: flurry.
Command line
shib run flurry -e '{{}}'shib manual flurrySource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/flurry.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org