Advertisement
Guest User

Untitled

a guest
Jul 27th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.99 KB | None | 0 0
  1. (defun mandelbrot3 (c n z0)
  2.   (declare (optimize (speed 3) (safety 0) (debug 0)))
  3.     (declare (type fixnum n))
  4.     (declare (type complex c z0))
  5.   (do ((i 0 (the fixnum (1+ i)))
  6.        (z z0 (the complex (+ (* z z) c))))
  7.       ((> i n)
  8.        z)))
  9.  
  10. (defun mandelbrot2 (c n z)
  11.   (declare (type fixnum n))
  12.   (declare (type complex c z))
  13.   (declare (optimize (speed 3) (safety 0) (debug 0)))
  14.   (if (= n 0) z
  15.     (mandelbrot2 c (- n 1)
  16.          (the complex (+ (* z z) c)))))
  17.  
  18. (defun mandelbrot (c n z)
  19.   (if (= n 0) z
  20.     (mandelbrot c (- n 1) (+ (* z z) c))))
  21.  
  22. (defun complex-print (z debug)
  23.     (format (string= debug "d") "z: ~a~%" z))
  24.  
  25. (defun main ()
  26.   (let* ((n (parse-integer (cadr *posix-argv*)))
  27.      (fn (caddr *posix-argv*))
  28.      (debug (cadddr *posix-argv*))
  29.      (z0 #C(0 0))
  30.      (c #C(0.04 0.01))
  31.      (z (cond
  32.           ((string= "1" fn) (mandelbrot c n z0))
  33.           ((string= "2" fn) (mandelbrot2 c n z0))
  34.           ((string= "3" fn) (mandelbrot3 c n z0)))))
  35.     (complex-print z  debug)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement