Try it online!
Try it online!
And vice versa.
This is a modification of the reverse quine. It's working to our advantage here that
! is used for printing and is also only one code point away from the the quote
". That makes it easier to make the quote printing section palindromic (the
'!+!'). Let's start with the first code:
This program has two entry points at the
Ls, which each creates a left-going atom. However, the right one immediately hits the
; which destroys it. The left one enters string mode and wraps around to the end, so that it prints the entire code (except the
") from back to front. That already gives us
_'!+!'L;L. All that's left is to print the
_ can be ignored,
'! sets the atom's mass to 33 (the code point of
+ increments it to
! prints it. That's all the output done. The
'L sets the atoms mass to the code point of
L but that's irrelevant.
; destroys this atom as well and since no atoms are left, the program terminates.
Now the other way round:
Again, we have two entry points but one atom is immediately destroyed. This time we move through the
!+!' section first, so we start by printing a quote. The
'_ is again irrelevant, but we need the
_ (or some other useless character) here to avoid
' escaping the
". The atom wraps to the end, traverses the source code once in string mode to print the rest of the program in reverse, the
L is then ignored and
; destroys the atom and terminates the program.