Messenger

From Esolang
Jump to navigation Jump to search

Messenger is an esolang created by squareroot12621, partially inspired by Orca. Its goal is to be the most annoying esolang.

Documentation

Messenger uses a 2D grid for its code, but instead of using variables and built-ins, Messenger uses messages and functions.

Messages

Messages can travel 1 character per tick, and they can travel horizontally or vertically. Messages can also get combined or split by functions.

However, messages don't wrap around when they hit an edge—instead, they get printed (if they hit the bottom or right edge) and disappear.

Messenger code is run by placing a message in the top-right corner of the grid. If there isn't a redirector (^, >, v, or <) there, the message "won't know where to go" and will throw an error.

Functions

Functions are characters on the grid itself that can move, split, or combine messages. Apart from the space (which doesn't do anything to messages), there are 29 functions. Any functions that aren't recognized throw an error.

Functions can take either 1 or 2 messages as input. If they take 2 messages, the argument order is determined by which message enters the function first. If both enter at the same time, an error is thrown. The last message also determines the output direction.

Here is a list of all functions recognized by Messenger:

Character Mnemonic Description
[space] Nothing; message passes through it.
< Left arrow Redirect message to the left (absolute)
> Right arrow Redirect message to the right (absolute)
^ Up arrow Redirect message to the top (absolute)
v Down arrow Redirect message to the bottom (absolute)
S Split Redirect message to left and right (relative)
N Null Message content = NULL
0 to 9 Message content = INT of number
L List Message content = LIST containing message content
I Input Message content = input (type is the same as when it came in)
+ Add Return msg1 + msg2
- Subtract Return msg1 - msg2 (INT only)
* Multiply Return msg1 * msg2 (INT only)
/ Divide Return msg1 // msg2, or NULL if msg2 is 0 (INT only)
W While Send message to left (relative) if positive INT or LIST, send message to right (relative) if nonpositive INT or NULL
= Equals Return 1 if msg1 == msg2, otherwise 0
G Greater than Return 1 if msg1 > msg2 (always LIST > INT > NULL), otherwise 0
B Beginning Send msg[:1] to left (relative), msg[1:] to right (relative)
E End Send msg[:-1] to left (relative), msg[-1:] to right (relative)
R Random Send message left (relative) 50% of the time, send message right (relative) 50% of the time
T Time Message content = Unix time in milliseconds (INT)

Sample Programs

Add two integers and print the result:

v>v
0I
>S>+
 >I^

Print "Hello, World!":

v>8v> *v>v >v >v >v>v >v  >v >v >v >v >v >v >v >v >v >v
>S    7>S>/S1>S>+S>S3>S>/ S7>S>-S>*S>-S>*S>/S>+S>-S>-S>v
 >9*^S^ 5  >+ 7    >+ 3 v S+ 5   3  9  9  7  3  6  8  3/
  vS ^  >^ vS^>^vS>vS^>^>   ^>^vS^ >^vS^ >^vS^vS^vS^vS^

Primality detector:

>0Iv v       1<
v <  *    S >-W
>vSSv >   S>* 0
v G1<>S >v>/  >
 >* >S>GW
>W >v2  >1
vSv >>S
6 8 v<>  *
v <  +1< > S
*      S < >S>
   ^<^ < ^  <

Interpreters

Messenger/Python interpreter (Github repository)
Note: The interpreter requires at least Python 3.8 to run.