Created
August 29, 2013 01:55
-
-
Save ericjang/6373482 to your computer and use it in GitHub Desktop.
Self-modifying homoiconic expression written in the Julia Language.
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
ex = quote | |
s = string(ex) | |
o = s | |
array = uint8(collect(s)) | |
for i = 1:length(array), bit = 0:7 | |
if rand() < 1/(length(array)*8) | |
array[i] $= (0x01 << bit) | |
end | |
end | |
s = bytestring(array) | |
try: | |
ex = parse(s) | |
eval(ex) | |
catch: | |
ex = parse(o) | |
eval(ex) | |
end | |
end | |
eval(ex) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment