Skip to content

Instantly share code, notes, and snippets.

@malisper
Last active April 17, 2016 22:23
Show Gist options
  • Save malisper/77db18aa8b1cb96fa7a984144eaf51aa to your computer and use it in GitHub Desktop.
Save malisper/77db18aa8b1cb96fa7a984144eaf51aa to your computer and use it in GitHub Desktop.
Quine Relay
(self-referential-version-of
'(lambda (self)
(format t
"#include <stdio.h>~%int main(){printf(\"%s\",~(~s~));}"
(remove #\newline (prin1-to-string self)))))
=>
((lambda (self)
(format t "#include <stdio.h>~%int main(){printf(\"%s\",~(~s~));}"
(remove #\newline (prin1-to-string self))))
((lambda (a)
(let ((b `',a))
(let ((ab `(,a ,b)))
`(,'(lambda (self)
(format t
"#include <stdio.h>~%int main(){printf(\"%s\",~(~s~));}"
(remove #\newline (prin1-to-string self))))
,ab))))
'(lambda (a)
(let ((b `',a))
(let ((ab `(,a ,b)))
`(,'(lambda (self)
(format t
"#include <stdio.h>~%int main(){printf(\"%s\",~(~s~));}"
(remove #\newline (prin1-to-string self))))
,ab))))))
=>
#include <stdio.h>
int main(){printf("%s","((lambda (self) (format t \"#include <stdio.h>~%int main(){printf(\\\"%s\\\",~(~s~));}\" (remove #\\newline (prin1-to-string self)))) ((lambda (a) (let ((b `',a)) (let ((ab `(,a ,b))) `(,'(lambda (self) (format t \"#include <stdio.h>~%int main(){printf(\\\"%s\\\",~(~s~));}\" (remove #\\newline (prin1-to-string self)))) ,ab)))) '(lambda (a) (let ((b `',a)) (let ((ab `(,a ,b))) `(,'(lambda (self) (format t \"#include <stdio.h>~%int main(){printf(\\\"%s\\\",~(~s~));}\" (remove #\\newline (prin1-to-string self)))) ,ab))))))");}
=>
((lambda (self) (format t "#include <stdio.h>~%int main(){printf(\"%s\",~(~s~));}" (remove #\newline (prin1-to-string self)))) ((lambda (a) (let ((b `',a)) (let ((ab `(,a ,b))) `(,'(lambda (self) (format t "#include <stdio.h>~%int main(){printf(\"%s\",~(~s~));}" (remove #\newline (prin1-to-string self)))) ,ab)))) '(lambda (a) (let ((b `',a)) (let ((ab `(,a ,b))) `(,'(lambda (self) (format t "#include <stdio.h>~%int main(){printf(\"%s\",~(~s~));}" (remove #\newline (prin1-to-string self)))) ,ab))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment