0587
Ten digits for lambdas, application and printing, and values kept safe inside functions.
InfiniteDonuts, 2020 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
InfiniteDonuts made 0587 in 2020, after 0815, Unlambda and 1337. A program is a single function application, written as digits in prefix order. 0 applies the expression after it to the one after that, and 1 makes a lambda out of the expression that follows.
Read the story
The specification calls a lambda that ignores its argument a monad. 1(Hello World) keeps the text inside a function. To get the value out, apply the monad to 9, the null value, which is what the lambda 1029 does. The specification says that is why 9 is in the language at all.
The machine
| Digit | Is |
|---|---|
0 f x | f applied to x |
1 e | A lambda with body e |
2 3 | The current function's argument; the current function |
4 | Print the argument and return it |
6 7 | The argument plus one; minus one |
9 | Null |
(text) | The literal text |
Whitespace between digits is skipped. This implementation leaves out 5, which gets input, because the specification does not say what it reads. It also leaves out 8, because the specification says only what it returns for (0), the identity function, and not what it returns for anything else.
Example
The second program applies the lambda 1 04 029 to the monad 1(Hello World).
The second program applies the lambda 1 04 029 to the monad 1(Hello World). Inside, 029 applies the argument to null and gets the text back, and 4 prints it.
Arguments are worked out before a function is applied, so the argument's print happens first.
Patterns it teaches
- Lambda encoding: a value lives inside a lambda and comes out when the lambda is applied.
Further
See also
Functional paradigm
Write your own in Run Convert a program from 0587
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: 0587.
Command line
shib run 0587 -e '04(Hello World)'shib manual 0587Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/0587.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org