View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

is this quine a cheat?

Home   How To   Code Pool   Public Library   Theory   Events
Uploaded Image: sicherheit.gif

// 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


Link to this Page