I am selfish

From Esolang
Jump to navigation Jump to search
I am selfish
Paradigm(s) imperative
Designed by User:Ttulka
Appeared in 2024
Dimensions one-dimensional
Computational class Turing complete
Major implementations Interpreter in JavaScript
File extension(s) .i

I am selfish is an esoteric programming language that solely discusses itself, permitting only variations of the symbol "I":

Symbol Encoded Unicode name
I \u0049 Latin capital letter I
Ι \u0399 Greek capital letter iota
І \u0406 Cyrillic capital letter Byelorussian-Ukrainian I
Ӏ \u04c0 Cyrillic letter Palochka

Language

Based on the symbols they are denoted by, instructions operate on one of four registers:

Symbol Encoded Register
I \u0049 0
Ι \u0399 1
І \u0406 2
Ӏ \u04c0 3

I am selfish has four instructions: increment, decrement, selection, and jump. Instructions are denoted as a unary number using one of the "I" symbols:

Number Instruction Meaning Example
1 Increment Increments the register I
2 Decrement Decrements the register II
3 Selection Skips the next instruction if the register is zero III
≥4 Jump Jumps to an instruction IIII, IIIII, IIIIII

Jump is unconditional; its target is determined by the number of symbols appended to the instruction. Four symbols refer to zero, five to one, six to two, and so on. It counts only instructions that use the same symbols as the jump itself.

Since only "I" symbols are allowed, instructions with different symbols must be used as separators; otherwise, the code would be ambiguous.

The selection and jump instructions together provide conditional jumps sufficient for Turing completeness.

Examples

(Newlines are added arbitrarily.)

Infinite loop

Never stops:

IIII

Addition

Add A and B (A = A + B):

ΙΙΙІІІІІΙΙIΙΙΙΙІІ

Multiplication

Multiples A with B (A = A × B):

IIIΙΙΙΙΙIIІIIIIΙΙΙІІІІІІІІІІΙΙІІІӀӀӀӀӀӀІІIӀІІІІІІӀӀӀΙΙΙΙΙӀӀІӀӀӀӀӀӀІІ

Fibonacci sequence

Computes the Fibonacci sequence starting with the elements in A and B, continuing until the number of elements specified in C:

ІІІӀӀӀӀӀӀӀӀӀӀІІΙΙΙIIIIIΙΙӀΙΙΙΙIIIӀӀӀӀӀӀӀIIΙIIIIIӀӀӀІІІІӀӀIΙӀӀӀӀӀӀІІӀӀ

Hello World

For computing "Hello World" the numbers in the registers must be interpreted as letters. It can achieved by defining a simple alphabet:

Letter Value
1
d 2
e 3
H 4
l 5
o 6
r 7
W 8

The following program sets A progressively to 4, 3, 5, 5, 6, 1, 8, 6, 7, 5, 2 which corresponds to "Hello World":

IΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙ
IΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙ
IΙΙIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙ
IΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙII
ΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙII
ΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIIΙΙII

External resources