Ichi
Ichi means 'one' in Japanese. Ichi is a one-instruction Turing-complete esoteric programming language created by User:TheCanon2.
Ichi was designed to be a Turing-complete language with even fewer operands than Divmeq. However, Ichi has flaws that make Divmeq better for demonstrating Turing-completeness.
- Negative integers
- Ability to grab new inputs (absent in some of the most popular esolangs)
- Complex arithmetic
- Output
Commands
Ichi has two unbounded registers with addresses 0 and 1. The Ichi command accepts only one operand, x
.
Change register with address x modulo 2 by the sign of x. If said register is -1, move 1 line forward. Else, goto line absolute of x, divided by 2 rounded down.
However, there are three exceptions.
If x is 0 or 1, print the value of register x and unconditionally move 1 line forward.
If x is -1, accept two numeric inputs to be written to the two registers and unconditionally move 1 line forward.
The latter is an instruction baked in to every Ichi program.
Line numbers start at 1 and increment by 1 for each line in the program. The program halts if the line number is greater than the length of the program.
Examples
Hello, World!
5 7 9 11 13 15 17 19 -23 40 24 26 28 30 32 34 36 38 18 -42 0 47 49 51 53 -57 76 58 60 62 64 66 68 70 72 74 52 -78 -80 0 84 86 88 90 92 94 96 0 0 102 104 106 0 111 113 115 117 119 121 123 125 127 -131 -146 -132 -134 -136 -138 -140 -142 -144 -126 -148 -150 0 -154 -156 -158 -160 -162 -164 -166 -168 -170 -172 -174 -176 0 181 183 185 187 189 191 193 195 197 199 -203 214 204 206 208 210 212 198 0 219 221 223 225 227 229 231 -235 242 236 238 240 230 -244 0 248 250 252 0 -256 -258 -260 -262 -264 -266 0 -270 -272 -274 -276 -278 -280 -282 -284 0 289 291 293 295 297 299 301 303 305 -309 -324 -310 -312 -314 -316 -318 -320 -322 -304 -326 -328 0
Prints the ASCII values of the characters in 'Hello, World!' since Ichi has no character output.
Quine
0
This is the smallest in a set of infinitely many Ichi quines with all-zero instructions.
Truth machine
-10 6 0 16 12 0 -10
Two-Time Cat
0 1
XKCD Random Number
4 6 8 10 0
A+B problem
4 -3 -8 0
A-B problem
-4 -3 8 0
Print all natural numbers
0 2
Computational class
Ichi is Turing-complete for it can simulate a two-register Minsky machine.
4
Increment register 0
-6 8 0
Decrement register 0 and jump to instruction 3 unless it is zero in which jump to instruction 4.
Implementations
The following Python script is an interpreter.
prgm = input('>Ichi ') prgm = list(prgm.split(" ")) for i in range(0, len(prgm)): prgm[i] = int(prgm[i]) prgm.insert(0, -1) # Initialises registers cells = [0, 0] # Executes program inst = 0 def ichi(x): global prgm global cells global inst if x == -1: cells = [0, 0] init = input('>i ') if len(init) != 0: init = list(init.split(" ")) if len(init) > 0: cells[0] = int(init[0]) if len(init) > 1: cells[1] = int(init[1]) inst += 1 elif x == 0 or x == 1: print(cells[x], end=" ") inst += 1 else: cells[x % 2] += int(x / abs(x)) if cells[x % 2] == -1: inst += 1 else: inst = abs(x) // 2 while inst < len(prgm): ichi(prgm[inst])