Minks

From Esolang
Jump to navigation Jump to search

Minks is a programming language based on a Minsky machine with two registers: the REGISTER and the register. Every instruction is preceded by a condition, which is a string of alphabetic characters. (Case is ignored here.) Conditions are like boolean variables: if they're set to True, the instruction will be executed; if False, it won't. Conditions start out as True.

Execution loops through the entire program until none of the conditions before any command is met (they're all False).

Instructions

Instruction Description
INC increment the REGISTER
inc increment the register
DEC condition if the REGISTER contains zero, set condition to False; otherwise decrement the REGISTER and set condition to True
dec condition same as DEC but with the register
OUT output the REGISTER modulo 256
out output the register modulo 256
INP take input and put it in the REGISTER
inp take input and put it in the register

Example programs

Hello, World!

The following program prints the word "HELLO", followed by a newline:

b INC b INC b INC b INC b INC b INC b INC b INC b INC b INC 
b INC b INC b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b OUT
b DEC c b DEC c b DEC c b OUT
b INC b INC b INC b INC b INC b INC b INC b OUT b OUT
b INC b INC b INC b OUT
b inc   b inc   b inc   b inc   b inc   b inc   b inc   b inc   b inc   b inc   b out
b dec b b dec b b dec b b dec b b dec b b dec b b dec b b dec b b dec b b dec b b dec b

Cat program

Assuming the instruction INP returns 0 on end of file.

while INP
  while DEC while
  while INC
while OUT

Truth-machine

a INP
a OUT

a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x
a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x
a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x
a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x
a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x
a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x a DEC x
a DEC b
a DEC loop
a dec a

b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b INC b INC b INC b INC b INC b INC
b INC b INC b INC b INC b INC b INC b INC b INC b INC

b INC b DEC loop
b dec b

loop OUT

Implementation

An implementation in Ocaml by User:Koen is on the talk page.