esolang

μ6

The μ-recursive functions of computability theory, written in sixteen symbols, numbers in base 6.

bforte · Turing complete: yes · ●●● hard

Tested with 4 known programs · Test method

Run it

Expected: foo

The idea

μ-recursive functions are one of the classic definitions of what can be computed. You start from zero, successor and picking an input, and build up with three rules, composition, primitive recursion and the μ operator, which searches for the first number that makes a function zero. μ6 is exactly that, one symbol per rule. Sixteen symbols fit in half a byte, so the interpreter's default source format packs two symbols into each byte; TIO runs the text form.

Read the story

Values are natural numbers or pairs of values. , packs its inputs into nested pairs, and printing with -a shows every number in the result as a character, so , followed by thirteen character codes in base 6 prints Hello, World.

The machine

This implementation follows the Haskell interpreter in the repository bforte/mu6, which is lazy; an input a function never looks at is never computed.

SymbolFunction
.Zero
+Add 1 to every number in the first input
/nThe n-th input, from 0
[f g1 g2 ...]f of the results of each g
#fgPrimitive recursion on the first input
@fThe first n with f(n, inputs) = 0
,Pack the inputs into pairs
< >The left or right of a pair

Numbers in the program are base 6, so 200 is 72. A pair of numbers x, y is the number 2^x (2y + 1) - 1, which < and > unpack.

Example

The second is the README's addition, recursion on 60, adding 1 to the result each step, starting from 5.
Expected: A
Expected: A

The second is the README's addition, recursion on 60, adding 1 to the result each step, starting from 5. The third builds the predecessor #./0, subtraction from it, and lets @ find the first n with 65 minus n equal to 0.

Patterns it teaches

Further

Also in Functional and concatenative

Write your own in Run Convert a program from μ6

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: mu6.

Command line

shib run mu6 -e ',250,303,303'
shib manual mu6

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/mu6.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language