Suc

From Esolang
Jump to navigation Jump to search

Suc is an esolang by User:ChuckEsoteric08 based on a Succesor machine

Specification

Suc uses unbounded amount of registers (which are 0-indexed) to store values. Line numbers are also 0-indexed.
There are only three commands:

INC x y

Increment register x by y.

CLR x

Set register x to zero.

JEQ x y z

If registers x and y are equal goto line z.
There is also optional command which is used for debuging:

OUT x

Which outputs value of register x. And thats it! Now try do to something useful with it

Some useful snippets

Unconditional jump:

JEQ x x z

Following examples use something called "label notation" which uses labels instead of line number:

a:

Would declare label a

Add registers x and y using temporary register z:

CLR z
inc:
INC x 1
INC z 1
JEQ z y done
JEQ x x inc
done:

Copy value of register x to register y:

CLR y
inc:
INC y 1
JEQ x y done
JEQ x x inc
done:

Multiply value of register x by 2 and use a and b as temporary registers:

CLR a
CLR b
inc:
INC a 2
INC b 1
JEQ b x done
JEQ b b inc
done:
CLR x
inc2:
INC x 1
JEQ x a done2
JEQ x x inc2
done2:

If we change it a little bit we could get division by 2:

CLR a
CLR b
inc:
INC a 1
INC b 2
JEQ b x done
JEQ b b inc
done:
CLR x
inc2:
INC x 1
JEQ x a done2
JEQ x x inc2
done2:

Decrement x using temporary registers y and z:

CLR y
CLR z
INC y 1
dec:
INC z 1
INC y 1
JEQ x y tox
JRQ x x dec
tox:
CLR x
cpy:
INC x 1
JEQ x z done
JEQ x x cpy

Computational class

The language is Turing-complete becauese it can simulate Incrementing machine. Insturction a b c d converts to:

a:
INC b 1
JEQ c d

See also