esolang

Hito

Ichi's one instruction, with input that leaves register 1 alone.

TheCanon2, 2024 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 9 known programs · Test method

Run it

Expected: 7

The idea

Hito means one, or person, in Japanese. TheCanon2 made it in 2024 after finding a flaw in its sister language Ichi. Ichi's input overwrites both registers, so nothing can be kept across a read. Hito reads into register 0 only, and only where a program asks for it with -1.

Read the story

A program is a list of integers, and each one is a whole instruction. Its parity picks one of two registers, its sign says whether to add or subtract 1, and half its size, rounded down, is the line to jump to. The jump is skipped when the register has just gone to -1, which is the only test there is. Every Ichi program that reads no input runs the same in Hito.

The machine

Two unbounded registers, 0 and 1, both 0 at the start. Lines are numbered from 1, and the run ends past the last one.

xDoes
0, 1Print register 0 or 1 and a space
-1Read a number into register 0
even xRegister 0 gets the sign of x added; jump to line |x| div 2, unless it is now -1
odd xThe same with register 1

The specification's interpreter reads one line for each -1, and an empty line gives 0. The end of the input gives 0 as well.

Example

The A+B.

The A+B. Lines 2 and 3 count the first number down into register 1, which ends one too high, and line 4 takes that one back. Line 5 reads the second number into register 0. Lines 6 and 7 count register 1 down onto it, line 8 takes back the extra one again, and line 9 prints.

The truth machine, and the cat that prints each number it reads until a 0 or the end of the input.

Expected: 0
Expected: 5 7

The XKCD random number counts register 0 up to 4 in four jumps and prints it.

Expected: 4

Patterns it teaches

  • One instruction: one number is a whole instruction.
  • Counter machines: the specification shows it runs a two register Minsky machine, which makes it Turing complete.

Further

OISC

Write your own in Run Convert a program from Hito

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run hito -e '0'
shib manual hito

Source

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

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

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