esolang

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

Expected: Hello World

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

DigitIs
0 f xf applied to x
1 eA lambda with body e
2 3The current function's argument; the current function
4Print the argument and return it
6 7The argument plus one; minus one
9Null
(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).
Expected: 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.

Expected: ab
Expected: 42

Patterns it teaches

  • Lambda encoding: a value lives inside a lambda and comes out when the lambda is applied.

Further

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 0587

Source

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