1 2;; mandelbrot set 3 4(define mandel 5 (lambda (rmin rmax imin imax res) 6 (letrec 7 ((rdelta (- rmax rmin)) (idelta (- imax imin)) 8 (rdelta1 (/ rdelta res)) (idelta1 (/ idelta res)) 9 (pcolor 10 (lambda (re im cre cim n) 11 (if (or (> n 200) (> (+ (* re re) (* im im)) 4.0)) 12 (let 13 ((c (* 8 (remainder n 8))) 14 (x (* res (/ (- cre rmin) rdelta))) 15 (y (* res (/ (- cim imin) idelta)))) 16 (draw-color 17 (* 255 (remainder n 2)) 18 (* 255 (remainder (quotient n 2) 2)) 19 (* 255 (remainder (quotient n 4) 2))) 20 (draw-move x y) 21 (draw-line (+ x 1) (+ y 1))) 22 (pcolor 23 (+ (- (* re re) (* im im)) cre) 24 (+ (* 2 re im) cim) 25 cre cim (+ 1 n))))) 26 (iter 27 (lambda (rep imp) 28 (if (> rep rmax) 29 (if (> imp imax) '() 30 (iter rmin (+ imp idelta1))) 31 (begin 32 (pcolor 0 0 rep imp 0) 33 (iter (+ rep rdelta1) imp)))))) 34 (iter rmin imin)))) 35 36(mandel -1.5 0.5 -1.0 1.0 25) 37 38