This Programming LanguagePlurp
Factoid: This programming languagePlurp is a two-dimensional programming language closely related to
><> (fish) and more distantly Befunge. It is based oninspired by ><>.
An infinite loop. Like in ><> 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 commandsPlurp.
Outputs 1 indefinitely (theoretically). Any number from 0
0 to 9
9 would do pretty much the same. Note: i
outputs the whole stack as a [non-delimited] string of numbers, s
as a string of characters - generated from the numbers on the stack.
Finally! Something interesting! This is a cat
cat program which outputs its input.
Demonstrates the pop
pop (~
) function. Although this pushes 1
to the stack, it is popped and ittherefore the program outputs nothing. (Not very interesting, I know.)
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:
The &
used in '39&'
concatenates the top two numbers on the stack [e.g. (39
-->is [3, 9]
|but 39&
-->is [39]
]).
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
"312", as the 3 wraps around.
\
can also 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, itThis has a surprising number of applications in this programming languagePlurp.
Yay! Stacks! This programming language, likeLike ><>, Plurp can create multiple stacks and run operations on themeach stack independent of other stacks (side note: this programming language has only one register and, unlike ><>, new registers are not created with new stacks)the others.
There are three different kinds of stacks - additive ([
), overlap ((
), and copy additive ({
). Stacks are classified by their behaviours when opened and closed with (]
) or flattened with (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;4[2]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;2]i;
outputs 2
).
Copy additive stacks are like additive stacks, but they open with the data of the nextlast stack (i.ealready in them. 4{11+]&i;2+]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.
What? Is this program not working correctly? No. As mentioned in the previous snippet, this programming language, likeLike ><>, Plurp has a register (albeit only a single one). When thea "
command is calledencountered, the interpreter checks if the register is empty. If it is, the top value on the stack is popped and pushed ontointo the register. Otherwise, the value in the register is popped and pushed ontointo the stack.
Therefore, even though there are two i
commands, only one outputs 42
because the other is called while 42
is in the register and not the stack.