Skip to content

Instantly share code, notes, and snippets.

@ericjang
Created August 29, 2013 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericjang/6373482 to your computer and use it in GitHub Desktop.
Save ericjang/6373482 to your computer and use it in GitHub Desktop.
Self-modifying homoiconic expression written in the Julia Language.
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