Quine / Reverse Quine
CJam, 17 16 bytes
{`"_~"+Wq~g#%}_~
Test it here.
A fairly straight-forward modification of the standard quine. Other solutions for 17 bytes:
{`"_~"+q~{W%}&}_~
{`"_~"+q~!2*(%}_~
If I can assume that the input is only 0 or 1 (as a stand-in for a boolean, which there is no dedicated type for in CJam), I get 15 by omitting the g
:
{`"_~"+Wq~#%}_~
Explanation
{`"_~"+ e# Standard generalised quine framework. Leaves the source code on the stack.
W e# Push a -1.
q~ e# Read and evaluate input.
g e# signum, turning truthy values into 1 (leaving 0 unchanged).
# e# Power. -1^0 == 1, -1^1 == -1.
% e# Select every Nth element: a no-op for 1 and reverses the string for -1.
}_~
Pyth, 17 bytes
_WQjN*2]"_WQjN*2]
A straightforward modification of the standard Pyth quine.
Gol><>, 9 bytes
'rd3*I?rH
I feel a little awkward posting this, since we already have ><>, Vitsy and Minkolang answers. The only additions to the standard quine are I
(read integer input), ?
(execute next if truthy) and r
(reverse stack).
Try it online.