Mandelbrot set: Difference between revisions
Content deleted Content added
m →Icon and Unicon: header simplification |
change base cases of iterations to 0, for simplicity and consistency |
||
Line 16:
# Compute the length of an orbit. #
PROC iterate = (COMPL z0) INT:
BEGIN COMPL z :=
WHILE (iter +:= 1) < max iter # not converged # AND ABS z < 2 # not diverged #
DO z := z * z + z0
Line 220:
cmplx c = x0 + (y0-d*y)*I
repeat(w):
cmplx w =
for i=0; i < max_i && cabs(w) < outside; ++i
w = w*w + c
Line 609:
(defn mandelbrot? [z]
(loop [c 1
m (iterate #(+ z (* % %))
(if (and (> 20 c)
(< (abs (first m)) 2) )
Line 820:
set pm3d map
set size square
splot [-2 : 2] [-2 : 2] mandelbrot (complex (
Output:
Line 829:
<lang haskell>import Data.Complex
mandelbrot a = iterate (\z -> z^2 + a)
main = mapM_ putStrLn [[if magnitude (mandelbrot (x :+ y)) < 2 then '*' else ' '
Line 1,805:
def mandelbrot(a): return reduce(lambda z, _: z*z + a, range(50),
def step(start, step, iterations): return (start + (i * step) for i in range(iterations))
Line 1,847:
def mandelbrot(a)
Array.new(50).inject(
end
Line 1,915:
(or (= n 0)
(*inside? z-0 (+ (* z z) z-0) (- n 1)))))
(*inside? z
(define (boolean->integer b)
|