#light #nowarn "57" //don't warn me about possibly deprecated features. open Microsoft.FSharp.Math open System let maxIteration = 100 let modSquared (c : Complex) = c.r * c.r + c.i * c.i type MandelbrotResult = | DidNotEscape | Escaped of int let ( !!!!!@** ) a = a * a let mandelbrot c = let rec mandelbrotInner z iterations = if(modSquared z >= 4.0) then Escaped iterations elif iterations = maxIteration then DidNotEscape else mandelbrotInner (( !!!!!@** z ) + c) (iterations + 1) mandelbrotInner c 0 let min a b = if (a > b) then b else a for y in [-2.0..0.1..2.0] do for x in [-2.0..0.05..1.3] do match mandelbrot (Complex.Create (x, y)) with | DidNotEscape -> Console.Write " " | Escaped e -> Console.Write (min 9 e) Console.WriteLine ()