Created
May 26, 2009 04:19
-
-
Save dagbrown/117888 to your computer and use it in GitHub Desktop.
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
# 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