My snowflake entry and source code.
import Complex import System type C = Complex(Double) mandelbrot_eval::Int->C->Int mandelbrot_eval max_iter c = length $ (takeWhile (\z -> (magnitude z) < 2)) $ (take max_iter) $ (iterate (\z -> z*z+c) (0:+0) ) half_width_pixels::Int half_width_pixels = 400 scaling::Double->Int->Double scaling width = (* (width /(fromIntegral half_width_pixels))) . fromIntegral range::Double->[Double] range width= map (scaling width) [-half_width_pixels .. half_width_pixels] iterations::Int iterations = 200 main::IO () main = do{ let {s = show (2*half_width_pixels+1)}; putStrLn ("P3\n"++s++" "++s++"\n"++"255"); args <- getArgs; let {side = exp(-(read (head args)))}; putStr $ unlines $ map show $ concatMap ( (\i -> [i,i,(i+55)]) . (mandelbrot_eval iterations) . (+ center) ) $ [x:+y | x<-(range side), y<-(range side)] } center::C center = 0.4245127190 :+ 0.2075302281
No comments :
Post a Comment