
// jrh asks:
// is this quine a cheat?
{ thisFunction.asCompileString ++ ".value" }.value
// Jens Gulden:
// this one isn't
// This should be one continuous line of code, but line breaks have been added for ease of reading
{ |a="", b=""| if (a!="", { a ++ "\"" ++ a.escapeChar($\\).escapeChar($\") ++ "\", \"" ++
b.escapeChar($\\).escapeChar($\") ++ "\"" ++ b }, { thisFunction.value("{ |a=\"\", b=\"\"| if (a!=\"\", { a ++ \"\\\"\" ++
a.escapeChar($\\\\).escapeChar($\\\") ++ \"\\\", \\\"\" ++ b.escapeChar($\\\\).escapeChar($\\\") ++ \"\\\"\" ++ b },
{ thisFunction.value(", ") } ) }.value") } ) }.value
// Julian writes // here is an example of a quine with partial application: (_ + '.(*' + quote(_) + '! 2)').(*"(_ + '.(*' + quote(_) + '! 2)')" ! 2)
// the same with normal function syntax:
{|x| x ++ '.(' ++ quote(x) ++ ')' }.("{|x| x ++ '.(' ++ quote(x) ++ ')' }")
A quine with surplus
[jrh] translate code to audio (delta times)and reconvert it to code to reproduce original source code
{|x|
var dt = 0.00019;
{
var num, u, t;
x = x ++ '.(' ++ quote(x) ++ ')';
x.do {|x| num = num.add(x.ascii * dt) };
u = TDuty.ar(Dseq(num), doneAction:2);
t = Timer.ar(u);
SendTrig.ar(u, 0, t);
u * 0.5
}.play;
OSCresponder(s.addr, '/tr', { |t,r,msg| (msg[3] / dt).asInteger.asAscii.post }).add;''
}.("{|x|
var dt = 0.00019;
{
var num, u, t;
x = x ++ '.(' ++ quote(x) ++ ')';
x.do {|x| num = num.add(x.ascii * dt) };
u = TDuty.ar(Dseq(num), doneAction:2);
t = Timer.ar(u);
SendTrig.ar(u, 0, t);
u * 0.5
}.play;
OSCresponder(s.addr, '/tr', { |t,r,msg| (msg[3] / dt).asInteger.asAscii.post }).add;''
}")
Some good quine links
- http://www.eleves.ens.fr:8080/home/madore/computers/quine.html A very detailed page about quines
- http://en.wikipedia.org/wiki/Quine Wikipedia Quine Page
- http://c2.com/cgi/wiki?SuperCollider Quines on the C2 wiki
- http://http://www.nyx.net/~gthompso/quine.htm Program Code Poetry
- http://homepage.mac.com/kpreid/quines.html Categorized list of Quines
- http://rohanpm.net/blog/quines-shakespeare-programming-language Quines and obscure programming languages
- http://www.cs.indiana.edu/~tanaka/GEB/quine.html Notes of ome thoughts about quines
- http://www.winface.com/inside/quine.html security and other implications
- http://www.latrobe.edu.au/philosophy/phimvt/joy/jp-reprod.html self replicating programs and lazy lists