esolang

Coin

Every value is a coin toss that has not happened yet.

None1, 2026 · Turing complete: no · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: 02001110

The idea

None1 made Coin in 2026. It has one constant, C, which is 0 or 1 at even odds, and no number literals at all. Arithmetic on C does not toss it. C+C is kept as the expression C+C, and only when it is printed are both coins tossed, so it prints 0, 1 or 2. Printing the same variable twice can give two different answers.

Read the story

The only sure data comes from the input, and from expressions whose answer does not depend on the toss. C%C is always 0, because x % 0 is 0 and x % 1 is 0 too. Then -~(C%C) is always 1, and from 1 every number can be built.

The machine

LineDoes
name=expressionKeep the expression in a variable
name< name<<Read a number or a character into a variable
name> name>>Toss every C in it and print it as a number or a character

Expressions use + - * / % & | ^ ~ << && || ! ( ) > < >= <= == != on whole numbers of any size. Division and modulo by 0 give 0. The specification does not say how the operators bind, so they bind and work as in C. There are no loops, so every program ends. C tosses a fixed pseudo-random sequence, so a run always prints the same.

Example

Two coins at a time.

Two coins at a time. The answers are what the fixed sequence gives.

The Hello World adds _, which is -~(C%C), 72 times for H. Doubling gets there sooner.

Expected: Hi

Input makes a coin that always lands the same way.

Expected: 48

Patterns it teaches

Further

Probabilistic

Nondeterministic

Write your own in Run Convert a program from Coin

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run coin -e '_<<
_>>' --input 'a'
shib manual coin

Source

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

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

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