Iris
Every list of numbers is a program. Whatever a random change does to it, it still runs and prints something.
Montywest, 2012 · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
Montywest made Iris, short for Interesting Random Instruction Sets, in 2012 and named it for his wife. He wanted code that still does something after random changes, so that small mutations and selection might evolve a working program. There are no syntax errors. A program is one list of numbers, and the same number can be a function call, a reference, a value or an operator, depending on where the pointer meets it. Large numbers fold down with a remainder. The function is n % 3, and an odd or even number chooses between a number and a cell of R.
The machine
List A is the program and list R holds the data. A pointer walks A from the start.
| n % 3 | Function | Then |
|---|---|---|
| 0 | Assignment | cell of R, number of operators, expression |
| 1 | Go | location, calls before coming back |
| 2 | Flow | iterations, calls, skipto, condition |
An expression is reverse Polish. A value is a choice and a number; an odd choice takes the number itself, an even one the cell of R it names. A negative number where a reference or a count goes also means a cell of R, so -.1 is R[0]. Assignments use + - * / ** % and conditions == < > != <= >= and or xor. The interpreter evaluates 3 2 - as 2 - 3, as the specification warns.
Flow is if, while and for in one. Iterations 1 make an if, 0 a while, and more a for loop with a condition.
A run ends by printing R, every cell followed by |, and then the reason. It ends when the pointer leaves A, at the 10,000th call, on a division or remainder by 0, or when a result is so large or so small that Perl prints it with an e. This implementation follows the Perl interpreter in the specification, with Perl's 64 bit whole numbers and its doubles printed to 15 digits.
Example
The single statement.
The single statement. It reads as R[1] = R[1] + 2 on an empty R, so R[0] stays empty.
Reverse Polish the other way round. The values 2 and 3 and then operator 1, minus, give 3 - 2.
The Fibonacci program with 10 rounds of its Flow instead of 3000. R[0] counts, R[1] and R[2] point back, and the sequence starts at R[3].
With 3000 rounds it runs until R[96] holds 12200160415121876738, the largest Fibonacci number below 2 to the 64th. The next sum is no longer a whole number for Perl, it prints as 1.97402742198682e+19, and the e ends the run with dump_ message is big-ass number, just as the specification shows. The comma delimited copy of this program lacks one 0 and stops in its first round.
Patterns it teaches
- Every text runs: any list of numbers is a program, made to be evolved.
Further
See also
Also in Artificial life
Write your own in Run Convert a program from Iris
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: iris.
Command line
shib run iris -e '0,1,1,1,2,2,1,0'shib manual irisSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/iris.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org