Minimal operation language

From Esolang
Jump to navigation Jump to search
Not to be confused with Minimal.

Minimal operation language is a test esolang by User:PythonshellDebugwindow.

Syntax

Each line is a sequence of unsigned integers of arbitrary size separated by operators (other than lines with goto), e.g.:

1 + 2 - 3 * 4 / 5

Spaces (other than newlines) don't matter. The result of each line is printed to STDOUT with a newline, so the above code would print:

0

because with Minimal operation language's OOO (see #Operators), and / being floor division:

(1 + 2) - ((3 * 4) / 5) = 0.6

Any question marks will be replaced with user input with the prompt ? , e.g.:

?

is a numeric cat program. Also:

1?5

with input 7 gives:

175

or with input 123 gives:

11235

or with input abc gives:

105

because abc is not a valid integer in Minimal operation language (regex: [0-9]+, no preceding + allowed).

Operators

Operator Operation Precedence
+ Addition 5
- Subtraction 6
* Multiplication 3
/ Floor division 4
^ Exponentiation 2
( Grouping 1
) Grouping 1
== Equality 7
!= Inequality 8

Precedence is 1 for highest, meaning the higher the precedence, the sooner that operation will be solved. The subtraction operator returns the absolute value of its result, the equality operator returns 1 if its LHS and RHS are the same, otherwise 0, and the inequality operator returns 0 if its LHS and RHS are the same, otherwise 1.

Gotos

When a line starts with : (colon), the program will jump to the (0-based) Nth line of the program, where N is the number on the line after evaluation (minus the colon). The number on the line will not be printed, and jumping to an out-of-range line will terminate the program without an error. If a line starts with ; (semicolon) instead of :, then the number on the line will be printed before the jump, e.g.:

1 + 1
:0

would print out 2 forever, and:

1 + 1
;0

would print out 2 (followed by 0) forever (2\n0\n2\n0...).

Conditional gotos

If you prefix a : or ; with a number, then the jump will only happen if that left number is not equal to 0. If a : is used, then no value will be printed out, even if the left number is equal to 0, but if a ; is used, then the right value will be printed out. For example:

?:3
0
:4
1

will print out 0 if user input is invalid or equal to 0, and will print out 1 otherwise. This example can be easily modified into a truth-machine.

Examples

Numeric cat

?

Add two inputs

? + ?

Truth-machine

?:3
0
:5
1
:3

Resources