Jump to content

Quine (computing): Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Hfastedge (talk | contribs)
No edit summary
examples
Line 1: Line 1:
[[pl:Quine]]
A '''quine''' is a [[computer program]] that produces its complete [[source code]] as its only output.
A '''quine''' is a [[computer program]] that produces its complete [[source code]] as its only output.
It is often used for [[Hacking|hackish]] amusement to try and develop the shortest possible quine in any given [[programming language]].
It is often used for [[Hacking|hackish]] amusement to try and develop the shortest possible quine in any given [[programming language]].
Line 24: Line 25:


----
----
[http://www.nyx.net/~gthompso/quine.htm More examples]
''perhaps add some more Quines here''
''perhaps add some more Quines here''

Revision as of 12:34, 25 May 2003

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."

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 LIST



More examples perhaps add some more Quines here