This Programming Language
Factoid: This programming language is a two-dimensional programming language closely related to
><> and more distantly Befunge. It is based on ><>.
1 character
>
An infinite loop. Like ><> and Befunge, code will wrap around in this programming language. Note that in the interpreter, this will not result in an infinite loop as the interpreter gives up after (by default) 2048 commands.
In fact, any command but ;
when by itself in a program would result in an infinite loop.
2 characters
1i
Outputs 1 indefinitely (theoretically). Any number from 0
to 9
would do pretty much the same.
3 characters
)s;
Finally! Something interesting! This is a cat
program which outputs its input.
4 characters
1~i;
Demonstrates the pop
(~
) function. Although this pushes 1
to the stack, it is popped and it outputs nothing. (Not very interesting, I know.)
5 characters
'a's;
Prints a
. This demonstrates the string parsing function: when an '
is encountered, the rest of the characters are pushed to the stack as character codes until another '
is encountered. This leads to the escape for '
being quite costly: '39&'
(Note: &
concatenates the top two numbers on the stack [e.g. 39
--> [3, 9]
| 39&
--> [39]
])
6 characters
123\i;
Demonstrates the right-shift function. 1
, 2
, and 3
are pushed onto the stack, then the stack is shifted right (by one position). The output of this program is 312
. \
can be replaced with |
(the left-shift operator) to shift the stack one position left instead of right. While this does not seem to be very interesting, it has a surprising number of applications in this programming language.
7 characters
8[42i];
Yay! Stacks! This programming language, like ><> can create multiple stacks and run operations on them independent of other stacks (side note: this programming language has only one register and, unlike ><>, new registers are not created with new stacks). There are three different kinds of stacks - additive ([
), overlap ((
), and copy additive ({
). Stacks are classified by their behaviours when opened and closed (]
) or flattened (f
). Additive stacks will be empty when open ([]
) and will add their data to the end of the next stack when closed (i.e. 4[11+]&i;
outputs 42
). Overlap stacks will be empty when open and will add their data to the beginning of the next stack when closed (i.e. 4(11+]&i;
outputs 2
). Copy additive stacks are like additive stacks, but they open with the data of the next stack (i.e. 4{11+]&i;
outputs 442
). A stack trace of this program is as follows: [8] [8][4] [8][42] [8]["42"] [842] [end]
, where ""
indicates something that is outputted.