From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.

Math&Matrix is a language based on a matrices list. Each matrix in this list is an instruction based on math properties (determinant, invertibility, diagonal/triangle equivalant, ...) This language is stack-based


A matrix is represented with the following syntax:


where # and n is an integer number.
Each line begin with a number must have the same number of integer (otherwise, it return an error)

*n represent a division coefficient. Each number in this matrix are divide by n. It is the only way to make a float
if n = 1, this line is optional

;; end the program

So, a Math&Matrix program looks like this:



+, -, *, /, %, ^: pop 2 values a and b and push a op b
push A: push A into the stack
copy: duplicate the top value and push it into the stack
swap i, j: pop 2 values i and j and swap the position of the i-th and the j-th element
del: discard the top value
instr: input a char and push the ASCII code into the stack
outstr: pop the top value and print the char which correspond to the ASCII code
inint: input an integer and push it into the stack
outint: pop the top value and print it

if C, n: pop 2 values a and b. If a C b then continue, else skip the next n instruction(s)
for n: pop a value A. Execute the next n instruction(s) A time(s)
while C, n: Execute the next n instructions while a C b is true. It pop 2 values at the beginning of the loop. The loop stop if the stack contain less than 2 values.

stop: stop the program

Matrix form

+, -, *, /, %, ^: all 2x2 matrix where opcode = det % 6

0 1 2 3 4 5
opcode + - * / % ^

push A: all non-square matrices (except 2x3)
where l and c are the number of line and column in the matrix

copy: 1 rank 2x3 matrix
del: 2 rank 2x3 matrix
swap i, j: (not implemented yet)

instr, inint: 4x4 orthogonal matrix
outstr, outint: 4x4 non orthogonal matrix

while: 3x3 matrix where the diagonal matrix equivalent have this form :

0 1 2 3 4 5
C < > <= >= == !=

for: 3x3 matrix where the triangle matrix equivalent have this form :