Like a quine, but not

2

2

Very simple, write a program that at first glance appears to be a quine, but is not. Upon running, the program actually prints the source to a real quine, obviously distinct from the original program in some way, preferably creative, but since this is a popularity contest, the answer with the most upvotes wins.

Standard Loopholes which are no longer funny are forbidden.

Christopher Wirt

Posted 2015-04-27T13:51:27.413

Reputation: 275

Question was closed 2016-04-24T03:38:34.503

Can I allow requiring specific input in my answer, or does my program have to work regardless of input? – ASCIIThenANSI – 2015-05-13T17:13:01.317

I think it has to work regardless of the input. – SuperJedi224 – 2015-05-13T21:05:48.370

Why does this question have so many dislikes? – Loovjo – 2015-05-31T12:15:54.930

@loovjo I have no idea. Vague? Open ended? – Christopher Wirt – 2015-05-31T23:13:47.770

4

I'm voting to close this question as off-topic because it's an [underhanded] challenge, which was on-topic a year ago, but is now off-topic by community consensus.

– James – 2016-04-23T20:21:43.243

Answers

18

CJam

{"_~"}_~ 

Well, whether this looks like a real quine to you depends on whether you're used to CJam or GolfScript, but anyway, it looks like and prints the standard quine:

{"_~"}_~

Wait, isn't that the same thing?

Nope, there's a space at the end of the first code. I believe the same thing would work in almost any language with almost any quine.

Test it here.

Martin Ender

Posted 2015-04-27T13:51:27.413

Reputation: 184 808

3CJam. What can it do? Everything, apparently... – ASCIIThenANSI – 2015-04-29T16:44:13.530

12

H9+

"Hello, world!"

It's easy: In H9+, anything other than H, 9, or + is ignored, and therefore, this is a quine. Or is it?

Nope. H actually outputs Hello, world!, with no quotes.

ASCIIThenANSI

Posted 2015-04-27T13:51:27.413

Reputation: 1 935

9

Python

s="s=%r\nprint(s%%s)"
print(s%s)

Explanation:

The output actually has single quotes instead of double quotes.

Try it here

mbomb007

Posted 2015-04-27T13:51:27.413

Reputation: 21 944

4

Mathematica

This one can be quite tricky to newer users.

Function[Print[StringJoin[ToString[FullForm[#0]], "[];"]]][];

Explanation:

Some people might not notice the #0 as not being part of the FullForm. In the output, it is replaced with Slot[0]. Everything else is the same.

LegionMammal978

Posted 2015-04-27T13:51:27.413

Reputation: 15 731

1

Haskell

Recursion can be tricky at times.

let s = "let s = " ++ show s ++ " in putStrLn s" in putStrLn s

This actually outputs the same as 's = "let s = " ++ show s in putStrLn s', namely 'let s = "let s = \"let s = \\\"let s = \\\\\\\"let s = \\\\\\\\\\\\\\\"let s = \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"...'


Basically, Haskell is trying to let s be equal to itself, with let s = appended to it, and escaping the string.


Obviously, in order to escape " you need \", and in order to escape \ you get \\, which is how the long stream of backslashes is formed.

YoYoYonnY

Posted 2015-04-27T13:51:27.413

Reputation: 1 173