The MATL language is stack-oriented. Data are pushed onto and popped out of a stack. Functions may take a number of elements from the stack (usually those at the top) and push one or more outputs onto the stack. Since the functions use data that’s already present in the stack, reverse Polish (or postfix) notation is used.
To ease stack handling, values from the stack can also be copied and pasted using several clipboards. These are similar to variables in other stack-based code-golf programming languages.
The main goal in designing the language has been to keep it as close to MATLAB as possible. MATL includes functions equivalent to most commonly used MATLAB functions. It should be very easy for a MATLAB user to start programming in MATL within minutes.
Language specification and compiler
The specification document and compiler files can be found on GitHub. The compiler works in MATLAB R2015b and newer versions. Probably in older versions too, except for some specific functions. It is also compatible with Octave 4.0.0. The compiler tries to ensure consistent behaviour in both platforms.
The language is subject to changes. This may cause old MATL code not to run in newer versions. However, old versions of the compiler and specification are kept in GitHub.
The contents of the stack are automatically printed at the end of the program.
To run this with the compiler you need to duplicate quotation marks, as usual, and include the whole program within single quotation marks. Or type
matl, then enter
'Hello, world!' on a separate line, then press enter twice.
Inputs a number n ≥ 2 and prints the first n Fibonacci numbers.
1 % number literal t % duplicate top element i % input number n 2 % number literal - % subtract. Produces n-2 : % vector of equally spaced values: [1, 2, ... , n-2] " % for loop. There will be n-2 iterations y % duplicate second-top element y % duplicate second-top element + % addition of top two elements % implicitly end for loop % implicitly display stack contents, bottom to top
This can be run with the command
matl '1ti2-:"yy+'. Or try it online!