Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Quine (computing)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Ouroboros programs== The quine concept can be extended to multiple levels of recursion, giving rise to "[[ouroboros]] programs", or quine-relays. This should not be confused with [[#Multiquines|multiquines]]. ===Example=== This Java program outputs the source for a C++ program that outputs the original Java code. <!-- NOTE TO EDITORS: The following code is very fragile. If you edit it, be very careful not to break it -- verify that the output of the Java program is identical to the C++ program, and that the output of the C++ program is identical to the Java program. --> <div style="width: 49%; overflow: auto; float: right; padding-left: 1%;" > <syntaxhighlight lang="cpp"> #include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { char q = 34; string l[] = { " ", "=============<<<<<<<< C++ Code >>>>>>>>=============", "#include <iostream>", "#include <string>", "using namespace std;", "", "int main(int argc, char* argv[])", "{", " char q = 34;", " string l[] = {", " };", " for(int i = 20; i <= 25; i++)", " cout << l[i] << endl;", " for(int i = 0; i <= 34; i++)", " cout << l[0] + q + l[i] + q + ',' << endl;", " for(int i = 26; i <= 34; i++)", " cout << l[i] << endl;", " return 0;", "}", "=============<<<<<<<< Java Code >>>>>>>>=============", "public class Quine", "{", " public static void main(String[] args)", " {", " char q = 34;", " String[] l = {", " };", " for(int i = 2; i <= 9; i++)", " System.out.println(l[i]);", " for(int i = 0; i < l.length; i++)", " System.out.println(l[0] + q + l[i] + q + ',');", " for(int i = 10; i <= 18; i++)", " System.out.println(l[i]);", " }", "}", }; for(int i = 20; i <= 25; i++) cout << l[i] << endl; for(int i = 0; i <= 34; i++) cout << l[0] + q + l[i] + q + ',' << endl; for(int i = 26; i <= 34; i++) cout << l[i] << endl; return 0; }</syntaxhighlight> </div><div style="width: 49%; overflow: auto; float: left; padding-right: 1%;" > <syntaxhighlight lang="java">public class Quine { public static void main(String[] args) { char q = 34; String[] l = { " ", "=============<<<<<<<< C++ Code >>>>>>>>=============", "#include <iostream>", "#include <string>", "using namespace std;", "", "int main(int argc, char* argv[])", "{", " char q = 34;", " string l[] = {", " };", " for(int i = 20; i <= 25; i++)", " cout << l[i] << endl;", " for(int i = 0; i <= 34; i++)", " cout << l[0] + q + l[i] + q + ',' << endl;", " for(int i = 26; i <= 34; i++)", " cout << l[i] << endl;", " return 0;", "}", "=============<<<<<<<< Java Code >>>>>>>>=============", "public class Quine", "{", " public static void main(String[] args)", " {", " char q = 34;", " String[] l = {", " };", " for(int i = 2; i <= 9; i++)", " System.out.println(l[i]);", " for(int i = 0; i < l.length; i++)", " System.out.println(l[0] + q + l[i] + q + ',');", " for(int i = 10; i <= 18; i++)", " System.out.println(l[i]);", " }", "}", }; for(int i = 2; i <= 9; i++) System.out.println(l[i]); for(int i = 0; i < l.length; i++) System.out.println(l[0] + q + l[i] + q + ','); for(int i = 10; i <= 18; i++) System.out.println(l[i]); } }</syntaxhighlight></div> Such programs have been produced with various cycle lengths: * [[Haskell (programming language)|Haskell]] β [[Python (programming language)|Python]] β [[Ruby (programming language)|Ruby]]<ref>{{cite web |url = http://blog.sigfpe.com/2008/02/third-order-quine-in-three-languages.html |title = A Third Order Quine in Three Languages |author = Dan Piponi |date = 5 February 2008 }}</ref> * [[Python (programming language)|Python]] β [[Bash (Unix shell)|Bash]] β [[Perl]]<ref>{{cite web |url = http://www.stratigery.com/source.html#Ouroboros |title = Ask and ye shall receive: Self-replicating program that goes through three generations, Python, Bash, Perl |author = Bruce Ediger |access-date = 2011-03-17 |archive-date = 2011-02-23 |archive-url = https://web.archive.org/web/20110223164033/http://www.stratigery.com/source.html#Ouroboros |url-status = dead }}</ref> * [[C (programming language)|C]] β [[Haskell (programming language)|Haskell]] β [[Python (programming language)|Python]] β [[Perl]]<ref>{{cite web |url = http://hpaste.org/43501/multiquine |title = multiquine |author = b.m. |date = 1 February 2011 |archive-url = https://archive.today/20130415050710/http://hpaste.org/43501/multiquine |archive-date = 2013-04-15 |url-status = dead }}</ref> * [[Haskell (programming language)|Haskell]] β [[Perl]] β [[Python (programming language)|Python]] β [[Ruby (programming language)|Ruby]] β [[C (programming language)|C]] β [[Java (programming language)|Java]]<ref>{{cite web |url = http://blog.sigfpe.com/2011/01/quine-central.html |title = Quine Central |author = Dan Piponi |date = 30 January 2011 }}</ref> * [[Ruby (programming language)|Ruby]] β [[Java (programming language)|Java]] β [[C Sharp (programming language)|C#]] β [[Python (programming language)|Python]]<ref>{{cite web |url = http://ruslan.ibragimov.by/20-04-2013.quine-ruby-java-c-python |title = Quine Ruby -> Java -> C# -> Python |author = Ruslan Ibragimov |date = 20 April 2013 |language = ru |access-date = 20 April 2013 |archive-date = 4 March 2016 |archive-url = https://web.archive.org/web/20160304040341/http://ruslan.ibragimov.by/20-04-2013.quine-ruby-java-c-python |url-status = dead }}</ref> * [[C (programming language)|C]] β [[C++]] β [[Ruby (programming language)|Ruby]] β [[Python (programming language)|Python]] β [[PHP]] β [[Perl]]<ref>{{cite web |url = http://golf.shinh.org/reveal.rb?Quine/shinh+%28C+C%2B%2B+Ruby+Python+PHP+Perl%29_1194650418&rb |title = Quine by shinh (C C++ Ruby Python PHP Perl) |author = Shinichiro Hamaji |date = 10 November 2007 }} (this one is also a [[Polyglot (computing)|polyglot]])</ref> * [[Ruby (programming language)|Ruby]] β [[Python (programming language)|Python]] β [[Perl]] β [[Lua (programming language)|Lua]] β [[OCaml]] β [[Haskell (programming language)|Haskell]] β [[C (programming language)|C]] β [[Java (programming language)|Java]] β [[Brainfuck]] β [[Whitespace (programming language)|Whitespace]] β [[Unlambda]]<ref>{{cite web |url = http://asiajin.com/blog/2009/09/22/uroboros-programming-with-11-programming-languages/ |title = Uroboros Programming With 11 Programming Languages |author = Ku-ma-me |date = 22 September 2009 |access-date = 17 March 2011 |archive-date = 29 August 2011 |archive-url = https://web.archive.org/web/20110829204605/http://asiajin.com/blog/2009/09/22/uroboros-programming-with-11-programming-languages/ |url-status = dead }}</ref> * [[Ruby (programming language)|Ruby]] β [[Scala (programming language)|Scala]] β [[Scheme (programming language)|Scheme]] β [[Scilab]] β [[Bash (Unix shell)|Shell (bash)]] β [[S (programming language)|S-Lang]] β [[Smalltalk]] β [[Squirrel (programming language)|Squirrel3]] β [[Standard ML]] β ... β [[Rexx]] (128 (and formerly 50) programming languages)<ref>{{cite web |url = https://github.com/mame/quine-relay |title = Quine Relay - An uroboros program with 100+ programming languages |author = Yusuke Endoh |website = [[GitHub]] |date = 2 November 2021 }}</ref> * Web application β [[C (programming language)|C]] (web application source code consists of [[HTML]], [[JavaScript]], and [[CSS]])<ref>{{cite web |url = http://michaelwehar.com/quines/c_prints_javascript.html |title = C Prints JavaScript |author = Michael Wehar |date = 10 November 2019 |language = en }}</ref>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Quine (computing)
(section)
Add topic