Conglument
The general recursive functions of the textbook, on strings of bits, written without a single bracket.
Hakerh400, 2020 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 20 known programs · Test method
Run it
The idea
Hakerh400 made Conglument in 2020. It takes the definition of the general recursive functions word for word, three basic functions and three ways to combine them, but every value is a string of bits instead of a number. A program is one function, written in prefix. There are no brackets around operands. The arity of each function says how many operands follow it, so the interpreter can tell where each one ends.
The machine
| Code | Function |
|---|---|
.n | Takes n arguments and returns the empty string |
+0 +1 | Puts a 0 or a 1 in front of its argument |
%mn | Takes m arguments and returns number n, counted from 0 |
~ a b1 ... bn | a of the results of b1 to bn, all on the same arguments |
- a b c | Recursion on the first argument, a when it is empty, b when it starts with 0, c when it starts with 1, each given the rest and the result for the rest |
* a | Searches all strings, shortest first, for one that makes a start with 1 |
A letter names a function the first time it appears and repeats it after that, so ~a%10a is ~%10%10. White space is ignored even inside a number. The main function takes the input bits and returns the output. Arguments are worked out only when needed.
Example
The first program inverts the bits.
The first program inverts the bits. Its recursion puts a 1 in front of the inverted rest when the string starts with 0, and a 0 when it starts with 1. The second reverses a string; inside it, -~b+0ac~bd%21e~f+1d is a recursion that appends a 0, and it is used to move each bit to the far end. The third answers 1 because 0110 is a palindrome.
The truth machine gives back a 0, but on a 1 its search through all strings never ends.
Patterns it teaches
- Turing completeness: recursion and the unbounded search are all it takes.
- Encoding tricks: a 1 before every bit and a 0 at the end pack two strings into one.
Further
See also
Also in Functional and concatenative
Write your own in Run Convert a program from Conglument
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: conglument.
Command line
shib run conglument -e '.1' --input '0110'shib manual conglumentSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/conglument.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org