esolang

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

Expected: 1001

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

CodeFunction
.nTakes n arguments and returns the empty string
+0 +1Puts a 0 or a 1 in front of its argument
%mnTakes m arguments and returns number n, counted from 0
~ a b1 ... bna of the results of b1 to bn, all on the same arguments
- a b cRecursion 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
* aSearches 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.
Expected: 1100
Expected: 1

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

Further

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 conglument

Source

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