Omicron

From Esolang
Jump to navigation Jump to search
Omicron
Paradigm(s) Imperative
Designed by Dr. Kilobyte
Appeared in 2023
Memory system Cell-based
Computational class Turing complete
Major implementations Omicron interpreter
File extension(s) .omi

Omicron is a Turing-complete esoteric programming language made by Dr. Kilobyte in 2023. Full implementation at GitHub
Subject to change with further development

Instructions

Pointer starts at memory cell 0. Negative addresses are valid.
Memory cells store either a number (integer or floating point), or nil.
nil can be used in a program to test for an empty cell, erase a cell, etc. n denotes a number.

Name Description
(any number) Set current memory cell
!f Import program from file f and insert it into current program (pre-execution)
:n Mark position in program as n
@n Get value at memory cell n (can be nested, e.g. @@@n)
Pointer
> Increment memory pointer
< Decrement memory pointer
>> n Move memory pointer forward n
<< n Move memory pointer back n
~ n Move memory pointer to n
Arithmetic
++ Increment current memory cell
-- Decrement current memory cell
+ n Add n to current memory cell
- n Subtract n from current memory cell
* n Multiply current memory cell by n
/ n Divide current memory cell by n
// n Floor-divide current memory cell by n
^ n Raise current memory cell to the nth power
% n Divide current memory cell by n and set to the remainder
\ n Set current memory cell to its nth root
log n Set current memory cell to its base-n logarithm
round Round current memory cell
ceil Round up current memory cell
floor Round down current memory cell
sin Set current memory cell to its sine
cos Set current memory cell to its cosine
tan et current memory cell to its tangent
abs Set current memory cell to its absolute value
fact n Set current memory cell to n factorial
rand n1 n2 Set current memory cell to random number between n1 and n2 (inclusive)
pi Set current memory cell to pi
e Set current memory cell to e
Comparison
eq n Set current memory cell to 1 if it is equal to n, else 0
gt n Set current memory cell to 1 if it is greater than n, else 0
gte n Set current memory cell to 1 if it is greater then or equal to n, else 0
lt n Set current memory cell to 1 if it is less than n, else 0
lte n Set current memory cell to 1 if it is lesser then or equal to n, else 0
not Set current memory cell to 1 if it is 0, else 0
and n Set current memory cell to 1 if (current memory cell && n), else 0
or n Set current memory cell to 1 if (current memory cell || n), else 0
xor n Set current memory cell to 1 if (current memory cell ^ n), else 0
Flow
goto n Goto marker n
qoto q n1 n2 Goto marker n1 if current memory cell is equal to q, otherwise goto marker n2
wait Pause program until Enter is pressed.
stop End program
I/O
input Accept an integer value (0 if none given) and sets current memory cell
inputc Accept a single character (first if more than one given) and sets current memory cell to ASCII value
read f n Read nth byte (zero-based) from file f and set current memory cell
size f Set current memory cell to size of file f (bytes)
print Print current memory cell
printc Print ASCII character of current memory cell
write f Write ASCII char of current memory cell to file f (truncates file)
awrite f Append ASCII char of current memory cell to file f
writeb f Write current memory cell to file f (binary) (truncates file)
awriteb f Append current memory cell to file f (binary)
mem Prints the memory tape

Examples

Newlines are treated as spaces, so programs can be written on single lines or across multiple lines.

Hello, World!

72 printc
101 printc
108 printc printc
111 printc
44 printc
32 printc
87 printc
111 printc
114 printc
108 printc
100 printc
33 printc

Cat

inputc printc

Truth machine

input qoto 1 2 :1 print goto 1 :2

Pythagorean theorem

input ^ 2 > input ^ 2 + @0 \ 2 print

Fibonacci sequence

input - 2 > 1 print > 1 print > :1 @1 + @2 print << 2 @2 > @3 > ~ 0 -- qoto 0 3 2 :2 ~ 3 goto 1 :3 wait

Alternative; only final output

input - 2 > 1 > 1 > :1 @1 + @2 << 2 @2 > @3 > ~ 0 -- qoto 0 3 2 :2 ~ 3 goto 1 :3 ~ 3 print wait

Binary counter

:1 qoto nil 11 2
:11 < goto 4
:2 qoto 0 22 3
:22 > goto 1
:3 qoto 1 22 4
:4 qoto nil 44 5
:44 1 mem goto 1
:5 qoto 0 55 6 
:55 1 mem goto 1
:6 0 < goto 4

Implementation

https://github.com/DrKilobyte/Omicron