O
""
#a
!!
""
#b
!!
""
#c
& ,&
@U;
Braingolf: Try it online!
LMBM: Try it online!
Outputs abc
in LMBM, and cba
in Braingolf.
Explanation
LMBM is a 2d language, which allows us to selectively execute the code we want.
Meanwhile Braingolf is a 1d language, meaning it starts at the top left, and goes across each line, executing code. It terminates upon reaching the end of the code.
In LMBM, a marble is spawned at every uppercase O
when the program starts. Each tick it drops 1 character and executes the character. LMBM terminates once all marbles are destroyed.
A double quote "
in LMBM sets the marble to char mode, meaning the next character to execute is interpreted as a 1 char string literal, and the marble's value is set to the codepoint of the character.
However "
begins and terminates a string in Braingolf, automatically pushing the contents to the stack. Thankfully an empty string does nothing.
!
in LMBM prints the marble's value as a char, however this is the silent modifier in Braingolf. Thankfully in braingolf v1, modifiers are only held through no-ops, meaning they will be dropped when braingolf hits the empty string, which doesn't use modifiers (unlike v2 where they are held until used) so we don't have to make sure to consume that modifier before we try to print the stack.
In Braingolf #
is the char literal identifier, causing the codepoint of the next char to be pushed to the stack.
After passing through all of the characters (and in LMBM's case printing the first 2) we hit the last 2 lines.
The 2nd to last line does nothing in LMBM, as it simply drops through the space, a no-op.
In Braingolf however, the ampersand &
is the greedy modifier. Modifiers in Braingolf are held through no-ops such as the space, until an operator consumes them, so the first ampersand is held through the space until it hits the comma ,
Braingolf's flip operator. The greedy modifier is consumed here to cause Braingolf to flip the entire stack, rather than the top 2 items. Then another greedy modifier is hit.
This one is held through the newline to the at @
sign, this prints the entire stack as ASCII.
Meanwhile LMBM simply drops through the space into the U
, which prints the marble's value as ASCII and destroys the marble.
The U
also has a function in Braingolf, it pops the top of the stack and pushes range(0...n)
, but the stack is empty because we just popped and printed everything, so this does nothing.
ABC
instead ofabc
\$\endgroup\$cba
isabc
backwards; link, link, link, link, link, link, link, link, link \$\endgroup\$'ABC'
and'CBA'
is ok, leading/trailing whitespace/newlines ok but must be the same for both outputs \$\endgroup\$