Created
September 20, 2013 03:54
-
-
Save gnidan/6633103 to your computer and use it in GitHub Desktop.
coffeescript quine
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
escape = (str) -> | |
return '' if str is '' | |
first = str[0] | |
rest = str[1..-1] | |
first = if first is "'" or first is "\\" | |
"\\#{first}" | |
else | |
first | |
return first + escape(rest) | |
str = [ | |
'escape = (str) ->', | |
' return \'\' if str is \'\'', | |
' first = str[0]', | |
' rest = str[1..-1]', | |
' first = if first is "\'" or first is "\\\\"', | |
' "\\\\#{first}"', | |
' else', | |
' first', | |
' return first + escape(rest)', | |
'str = [', | |
']', | |
'for l in [0..9]', | |
' console.log str[l]', | |
'for l in str', | |
' console.log " \'#{escape(l)}\',"', | |
'for l in [10..16]', | |
' console.log str[l]', | |
] | |
for l in [0..9] | |
console.log str[l] | |
for l in str | |
console.log " '#{escape(l)}'," | |
for l in [10..16] | |
console.log str[l] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
woot!