-- Haskell 98
-- The MathematicalOrchid, 24 Feb 2007
import Data.Complex
quadratic c z = z*z + c
critical_orbit z = iterate (quadratic z) 0
pixel = length . takeWhile (\z -> magnitude z <= 2) . take max_iter
side n v0 v1 =
let sv = (v1 - v0) / fromIntegral n
in [v0, (v0 + sv) .. v1]
grid = map (\y -> map (:+ y) side_x) side_y
image = map (map (to_ascii . pixel . critical_orbit)) grid
main = mapM_ putStrLn image
side_x = side 64 (-2) 2
side_y = side 32 (-2) 2
max_iter = 16
to_ascii n = " .,:;|!([$O0*%#@" !! (n-1)
.
.......................
...............................
.....................................
...........................................
...............................................
.........,,,,,,,,,,,,,,,.........................
......,,,,,,,,,,,,,:::;|;:::,,,......................
....,,,,,,,,,,,,,::::;;|(*@@::::,,,....................
..,,,,,,,,,,,,,::::::;;|*O@@[|;;:::,,,,..................
..,,,,,,,,,,,,:::::;|||!(@@@@@(!|;;::,,,,..................
.,,,,,,,,,,,::::;;;|[@@0@@@@@@@@@$@$O;:,,,,,.................
,,,,,,,,,::;;;;;;||[0@@@@@@@@@@@@@@@[|;:,,,,,................
,,,,,:::;;|%(!((!!((@@@@@@@@@@@@@@@@@@@;::,,,,,................
,:::::;;;|![@@@@@@O*@@@@@@@@@@@@@@@@@@*;::,,,,,................
::::;||!(OO@@@@@@@@@@@@@@@@@@@@@@@@@@@|;::,,,,,................
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@O!|;::,,,,,,................
::::;||!(OO@@@@@@@@@@@@@@@@@@@@@@@@@@@|;::,,,,,................
,:::::;;;|![@@@@@@O*@@@@@@@@@@@@@@@@@@*;::,,,,,................
,,,,,:::;;|%(!((!!((@@@@@@@@@@@@@@@@@@@;::,,,,,................
,,,,,,,,,::;;;;;;||[0@@@@@@@@@@@@@@@[|;:,,,,,................
.,,,,,,,,,,,::::;;;|[@@0@@@@@@@@@$@$O;:,,,,,.................
..,,,,,,,,,,,,:::::;|||!(@@@@@(!|;;::,,,,..................
..,,,,,,,,,,,,,::::::;;|*O@@[|;;:::,,,,..................
....,,,,,,,,,,,,,::::;;|(*@@::::,,,....................
......,,,,,,,,,,,,,:::;|;:::,,,......................
.........,,,,,,,,,,,,,,,.........................
...............................................
...........................................
.....................................
...............................
.......................
.