esolang

{}s

Every number is a variable, so every constant has to be built from the only one there is, 2.

AmNow, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: 0

The idea

AmNow made {}s, said "Sets", in 2021. In {}s the number 5 does not mean five; it names variable 5. The one constant is %, which is 2. So 1 is {% / %}, 0 is {% - %} and 42 is {{% * % * % * % * %} + {% * % * %} + %}.

Read the story

There is no print and no read either. Writing variable 0 prints the value, and reading variable 1 reads the input.

The machine

CodeDoes
%The constant 2
5Variable 5
{ }Group an expression, or a list of statements
5<exprAssign to variable 5
[x, ...]Repeat what follows the comma while x is not 0
+ - * /Arithmetic, in the usual order
= \ ~ $Equal, not equal, less, greater
#Switch I/O between characters and numbers

&, @ and the bar are and, or and xor, and ! is not. I/O starts on characters, a variable never set is 0, and the end of the input reads as 0. The specification proves {}s Turing complete by turning every command of Portable Minsky Machine Notation into a few lines of it.

Example

The truth machine and the cat.

The truth machine and the cat. The cat stops on the 0 that the end of the input gives.

Expected: cat

The looping counter reads a number in number mode, switches back to characters and prints a growing row of 42s, which are asterisks, with a 10 after each row.

Expected: * ** ***

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from {}s

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run s -e '2<1 [2, {0<2 2<1}]' --input 'Hello, World!'
shib manual s

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/s.js

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

Source esolangs.org (CC0) · Edit on esolangs.org