Encyclopedia > Quine

  Article Content

Quine

A quine is a computer program that produces its complete source code as its only output. It is often used for hackish amusement to try and develop the shortest possible quine in any given programming language.

Quines are named after W. V. Quine, who made an extensive study of indirect self-reference: he coined, among others, the paradox-producing expression, "yields falsehood when appended to its own quotation."

Table of contents

Sample quine in C

 char x[]="char x[]=%c%s%c;%cint main() {printf(x,34,x,34,10,10);return 0;}%c";
 int main() {printf(x,34,x,34,10,10);return 0;}

Sample quine in LISP

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

Sample quine in Python

 a='a=%s;print a%%`a`';print a%`a`

Sample quine in Perl

 $_=q{$_=q{Q};s/Q/$_/;print};s/Q/$_/;print

Sample quine in BASIC

10 C=": PRINT CHR(49)+CHR(48)+CHR(32)+CHR(67)+CHR(61)+CHR(34)+C+CHR(34)+C": PRINT CHR(49)+CHR(48)+CHR(32)+CHR(67)+CHR(61)+CHR(34)+C+CHR(34)+C


More examples (http://www.nyx.net/~gthompso/quine.htm)
perhaps add some more Quines here



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
East Islip, New York

... family size is 3.38. In the town the population is spread out with 28.5% under the age of 18, 6.3% from 18 to 24, 32.3% from 25 to 44, 21.1% from 45 to 64, and 11.8% who ...

 
 
 
This page was created in 39.7 ms