Created
November 16, 2013 16:24
-
-
Save STRd6/7502129 to your computer and use it in GitHub Desktop.
Replicant Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Return a function | |
# that when called returns a string, | |
# that when evaluated executes the code and returns a function | |
# .. that when called returns a string, | |
# .. that when evaluated executes the code and returns a function | |
# .. .. | |
replicantGenerator = (code) -> | |
quine = -> | |
""" | |
var code = #{JSON.stringify(code)}; | |
Function(code)() | |
var quine = #{quine.toString()}; | |
return quine; | |
""" | |
replicant = replicantGenerator("console.log(\"hey\")") | |
console.log Function(Function(replicant())()())()() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment