Really not sure where to post this .... " Coding Life " ? ... " Serious Discussion " ? Anyway , post festive season .... and things can be a bit dull , so here is a little challenge . Write a program / script which when run gives as the output ONLY its own source code , .... and clearly , this is NOT the same as merely listing the code In some ways it is like an inverse of the classic " Hello World " type of thing. Use any language you like ( but as far as I know , it's only actually possible in a few ) It's tricky , and more difficult than it first appears ! But then with so much stuff online these days , maybe it's not that much of a challenge any more. Any initial thoughts from anyone ? .... post them here .... the ideas / strategies may be more interesting than actual working code !
@Mutoid: I did a little research and came up with Quine Computing. I think that's what you're talking about... http://www.nyx.net/~gthompso/quine.htm
That's a good find Michaela Joy . I remembered the quine concept from Hofstader's wonderful book " Godel , Escher Bach " but I didn't know of that website when I posted , and I had no idea that it could be done in so many languages. I guess it makes my little "challenge" a bit pointless I was starting to think that nobody else was interested .... after all , it achieves nothing practical .... just another bit of "navel gazing " really , but thanks for replying !
Hum, like this? Just save the below code with the ext: .bat or .cmd Code: @echo off :: This is a CheatingQuineBatchScript for /F "delims=" %%L in (%0) do echo %%L Or Code: @echo off :: This is a CheatingQuineBatchScriptWithPause for /F "delims=" %%L in (%0) do echo %%L pause If you don't want to navegate with the CMD. * edit: "Quines, per definition, cannot receive any form of input, including reading a file, which means a quine is considered to be 'cheating' if it looks at its own source code.", from: en .wikipedia .org/wiki/Quine_(computing) Oh, I see now. It's much harder, cheers!