Braingolf: Try it online!
No LMBM online interpreter available
abc in LMBM, and
cba in Braingolf.
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.
" 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, so we have to make sure to consume that modifier before we try to print the stack, that's what the
_ are for (
_ pops and prints the top of the stack, with the
$ modifier it doesn't print, and with the
! modifier it doesn't pop, so
!$_ consumes both modifiers without actually doing anything)
# 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 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.
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.