Pointless
No variables and no data but bits. A program is one function, built from three others.
2020 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Pointless is a point-free variation on 01_, from 2020. In 01_ a function names its arguments and matches patterns on them. In Pointless no function ever names its argument. Every expression is a function from a list of bits to a list of bits, and a program is one of them, applied to its input.
Read the story
There are three functions to start with. _ throws its argument away and gives the empty list, 0 puts a 0 in front of it and 1 puts a 1 there. Everything else is built from those, by writing functions side by side, by an if on the first bit, by joining two results and by LET, which names functions so they can call themselves.
The machine
| Expression | Does |
|---|---|
f g | f applied to the result of g |
(f,g,h) | f on an empty argument, g on the tail if the head is 0, h on the tail if it is 1 |
(f,g) | f of the argument followed by g of the argument |
LET f = ..., g = ... IN ... | Name functions; every body can use every name |
_ 0 1 | The empty list; a 0 or a 1 put in front |
A program ends with a dot, and == starts a comment. The input is the argument, as bits, and the result is the output. The Hello world fixes the order of the bits, each byte from its lowest bit up. Lists are lazy, so a function that never ends can still print.
Example
The cat takes the list apart at its first bit and puts the same bit back, so it gives its argument unchanged.
The cat takes the list apart at its first bit and puts the same bit back, so it gives its argument unchanged.
Eight functions that call each other in a ring count the bits of each byte. The sixth swaps 0 and 1, and that bit is the one between a capital and a small letter.
Patterns it teaches
- Combinators: no function names its argument; programs are built by composition alone.
Further
See also
Also in Functional and concatenative
Write your own in Run Convert a program from Pointless
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: pointless.
Command line
shib run pointless -e '(_,0,1).' --input 'cat'shib manual pointlessSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/pointless.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org