Skip to content

Instantly share code, notes, and snippets.

@STRd6
Created November 16, 2013 16:24
Show Gist options
  • Save STRd6/7502129 to your computer and use it in GitHub Desktop.
Save STRd6/7502129 to your computer and use it in GitHub Desktop.
Replicant Generator
# 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