Skip to content

Instantly share code, notes, and snippets.

@Antti
Forked from dagbrown/gist:117888
Created May 27, 2009 06:51
Show Gist options
  • Save Antti/118491 to your computer and use it in GitHub Desktop.
Save Antti/118491 to your computer and use it in GitHub Desktop.
# A nice demonstration of how much faster Ruby 1.9 is than Ruby 1.8
require "complex"
class Complex
def m
z=self
1024.times { |i| z=z*z+self; return i+1 if z.abs > 2 }
return 1024
end
end
(1.0).step(-1,-0.05) do |y|
(-2.0).step(0.5,0.0315) do |x|
print " .,:;~=/$@#"[(Math.log(Complex(x,y).m)/Math.log(2)).to_i].chr
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment