Underload

Basics

Underload is a stack-based programming language that works along similar lines to Muriel. Although not technically speaking a functional language, its evaluation operator ^ (which is the only form of flow control) makes programming in it functional in practice.

Reserved characters

The bracket and angle bracket characters []<> are reserved; if these are to appear anywhere in the program, they must be quoted by placing " before them. This also applies to the " character itself. Other characters must not be quoted with " (in particular, this means that Underload programs cannot output strings containing unmatched parentheses). Parentheses are moderately reserved, in that any Underload program must have matched parentheses to be legal.

Commands

Exceptional circumstances

Pretty much anything whose behaviour isn't specifically given here (for instance, running * on an empty stack) is an error.

Unlambda to Underload

The s, k, and i characters in Unlambda can all be translated directly into Underload. Also, the ` character can be translated, but it has to be moved to a postfix rather than prefix position, and .x can be translated for most values of x. These translations prove that Underload is Turing-complete, because it can be compiled into from the Turing-complete `sk Unlambda.

Example programs

Click on any of these programs to load them in the interpreter below.

Hello, world!

(Hello, world!)S

Fibonacci sequence

(()(*))(~:^:S*a~^a~!~*~:(/)S^):^
(An ski`. Unlambda version is ```s``s``sii`ki`k.*``s``s`ks``s`k`s`ks``s``s`ks``s`k`s`k./``s`k`sikk`k``s`ksk, which can also be loaded up in the interpreter below by clicking on it; you can automatically convert it to Underload if you wish to run it.)

Infinite loop

(:^):^
(This is exactly equivalent to the ski`. Unlambda program ```sii``sii; if the Unlambda program is converted to Underload using the compiler below and run for a while, it eventually ends up in the same state as the previous Underload program (the only difference being ~~, which has no effect, in the code derived from the Unlambda).

Quine

(:aSS):aSS
(The null program is also a quine. This program is more stack-based than functional.)

Online interpreter

When using this interpreter, note that newlines and spaces in code will cause errors unless they are inside () quoting; also, avoid newlines in Unlambda input, as different browers will interpret them in different manners, and some may crash as a result. The ski`. Unlambda to Underload compiler only supports the s, k, i, `, and .x commands; it doesn't even allow comments or spaces.
Program:

Stack:

Output:

Single-step through program
Run program (500ms delay) (100ms delay) (10ms delay)
Convert ski`. Unlambda to Underload
This HTML file has been released to the public domain by its previous copyright holder.