From Esolang
Jump to navigation Jump to search
Not to be confused with Matrix (data structure).

Matrix is a language which is programmed through a system of matrices. It is not two-dimensional and execution is performed through the use of the minimal number of keywords and the principles of matrix algebra.

Language Overview

There is a single entry point, denoted by "main" which is a matrix of undefined size. From here the elements of main can be anything from a constant double to an arithmetic operation. Doubles are the only data type Matrix accepts. There are few reserved keywords for accepting input and output.

main   The main entry point
in     Flags an element for input
out    Flags an element for out (default value of 1)

The value of out can be manipulated through matrix arithmetic. For example; the following program would print out the numbers 3, 9 and 7.

main = {
    { print * data } 

print = [

data = [

Notice that the matrix "main" with undefined size is encased in curly braces, where the matrices "print" and "data" have a constant size and are encased in square braces. The matrices "print" and "out" are multiplied and main is transformed into a 1x3 matrix with values 3, 9 and 7, all of which are flagged for printing and thus the output will be:


The same program could be reproduced using Matrix addition as follows:

main = { print + data }

print = [out, out, out]

data = [ [2, 8, 6] ]

However the values need to be reduced by 1 each in order to produce the same effect.

Execution of the elements of the main Matrix begins when it's final state has been calculated.