Cable Forum

Cable Forum (https://www.cableforum.uk/board/index.php)
-   General IT Discussion (https://www.cableforum.uk/board/forumdisplay.php?f=19)
-   -   Quine - self replicating code (https://www.cableforum.uk/board/showthread.php?t=35601)

ikthius 24-09-2005 20:42

Quine - self replicating code
 
ok,

I was shown this today and asked to try it out by a friend, so far what I can come up with might fail, I will get it eventually

but, I was going to see how many people would like to try it.

http://www.nyx.net/~gthompso/quine.htm
http://en.wikipedia.org/wiki/Quine

it can be done in most programming languages.

try to do it without cheating.

ik

p.s. I searched the forum for this, and it only came up with a quiz, so nothing else has been posted, i think

danielf 24-09-2005 22:39

Re: Quine - self replicating code
 
Quote:

Originally Posted by ikthius
ok,

I was shown this today and asked to try it out by a friend, so far what I can come up with might fail, I will get it eventually

but, I was going to see how many people would like to try it.

http://www.nyx.net/~gthompso/quine.htm
http://en.wikipedia.org/wiki/Quine

it can be done in most programming languages.

try to do it without cheating.

ik

p.s. I searched the forum for this, and it only came up with a quiz, so nothing else has been posted, i think

Great to see someone bring this up! (I hosted that quiz btw). They're mind boggling, those quines...

I use LISP on an almost daily basis, but I really cannot get myself to understand this (allegedly) classic quine:

((lambda (x)
(list x (list (quote quote) x)))
(quote
(lambda (x)
(list x (list (quote quote) x)))))

I'm not sure it counts though, as (in CLISP) some quotes become 's as below

[11]> ((lambda (x)
(list x (list (quote quote) x)))
(quote
(lambda (x)
(list x (list (quote quote) x)))))
((LAMBDA (X) (LIST X (LIST 'QUOTE X))) '(LAMBDA (X) (LIST X (LIST 'QUOTE X))))
[12]>

ikthius 25-09-2005 12:26

Re: Quine - self replicating code
 
I done it in java, although I am not convinced it is an exact replica, but it is close.

I was thinking about also finding the file and echoing the file to the screen, not sure if this is against the rules?

Code:

class QuineTest
{
        public static void main(String [] args)
        {
                char x = 32;
                System.out.println(y+x+';'+'}');
        }
        static String y ="class QuineTest{ public static void main(String [] args){ char x = 34; System.out.println(y+x+';'+'}');} static String y =";
       
}

although my code to make it work is not on the same line, I thought it would be easier this way, but you know it can be all put on the same line.

ik

danielf 25-09-2005 23:01

Re: Quine - self replicating code
 
That looks pretty impressive! :tu: I don't know Java though, so I haven't a clue as to what it does :)

But don't you have an additional semicolon in the output (last character)?


All times are GMT. The time now is 14:33.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum