2012-05-31 08:02:54 +00:00
|
|
|
-- The Mandelbrot function
|
|
|
|
module Mandel (mandel) where
|
|
|
|
|
|
|
|
import ExtComplex
|
|
|
|
|
2012-06-15 09:56:48 +00:00
|
|
|
mandel :: Float -> Float -> Float -> Int -> Int
|
2012-05-31 08:02:54 +00:00
|
|
|
mandel r i s nbIterations =
|
|
|
|
f (extcomplex r i s) 0 nbIterations
|
|
|
|
where
|
|
|
|
f :: ExtComplex -> ExtComplex -> Int -> Int
|
2012-06-11 14:53:26 +00:00
|
|
|
f _ _ 0 = 0
|
2012-05-31 08:02:54 +00:00
|
|
|
f c z n = if (magnitude z > 2 )
|
|
|
|
then n
|
|
|
|
else f c ((z*z)+c) (n-1)
|