Saturday, May 15, 2004
Quine = Self-Reproducing Code
I received a note from AG regarding self-reproducing code. "I presume by now you have seen a kazillions of these"...
...quine: /kwi:n/ /n./ [from the name of the logician Willard van Orman Quine, via Douglas Hofstadter] A program that generates a copy of its own source text as its complete output. Devising the shortest possible quine in some given programming language is a common hackish amusement. Here is one classic quine:
(list x (list (quote quote) x)))
(list x (list (quote quote) x)))))
This one works in LISP or Scheme. It's relatively easy to write quines in other languages such as Postscript which readily handle programs as data; much harder (and thus more challenging!) in languages like C which do not. Here is a classic C quine for ASCII machines:
For excruciatingly exact quinishness, remove the interior line breaks...
The Quine Page
at 8:40 AM