O
""
#a
!$
""
#b
!$_
""
#c
& ,&
@U
Braingolf: Try it online!
No LMBM online interpreter available
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, so we have to make sure to consume that modifier before we try to print the stack, that's what the !
and _
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)
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 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.
4I don't think this is a dupe at all. The fact that the string is reversed is different enough from printing two different strings. I won't (vote to) reopen, though, as that would have immediate effect – Luis Mendo – 2017-08-09T20:00:30.600
4I voted to reopen this post, because IMO printing the reverse of a String and a String is much different than 2 different ones. No answer can trivially be modified to fit this challenge. My own answer uses a reverse symmetry techinque when compared to the answers there. I agree with @LuisMendo. – Mr. Xcoder – 2017-08-09T20:04:08.997
Reopening now, as it has two votes in addition to mine – Luis Mendo – 2017-08-09T20:26:00.867
Is a leading newline allowed? – Zacharý – 2017-08-09T23:50:06.810
2Can you print
ABC
instead ofabc
– Oliver Ni – 2017-08-10T00:53:35.7235
I vote to reopen, some answers use the fact
– Oliver Ni – 2017-08-10T02:37:33.107cba
isabc
backwards; link, link, link, link, link, link, link, link, link2
'ABC'
and'CBA'
is ok, leading/trailing whitespace/newlines ok but must be the same for both outputs – Chris_Rands – 2017-08-10T07:56:14.2971@OliverNi Another reason it might not be considered a dupe is that the other question says "Different versions of the same language don't count", whereas that is allowed and indeed encouraged here – Chris_Rands – 2017-08-10T08:04:31.753