Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun mandelbrot3 (c n z0)
- (declare (optimize (speed 3) (safety 0) (debug 0)))
- (declare (type fixnum n))
- (declare (type complex c z0))
- (do ((i 0 (the fixnum (1+ i)))
- (z z0 (the complex (+ (* z z) c))))
- ((> i n)
- z)))
- (defun mandelbrot2 (c n z)
- (declare (type fixnum n))
- (declare (type complex c z))
- (declare (optimize (speed 3) (safety 0) (debug 0)))
- (if (= n 0) z
- (mandelbrot2 c (- n 1)
- (the complex (+ (* z z) c)))))
- (defun mandelbrot (c n z)
- (if (= n 0) z
- (mandelbrot c (- n 1) (+ (* z z) c))))
- (defun complex-print (z debug)
- (format (string= debug "d") "z: ~a~%" z))
- (defun main ()
- (let* ((n (parse-integer (cadr *posix-argv*)))
- (fn (caddr *posix-argv*))
- (debug (cadddr *posix-argv*))
- (z0 #C(0 0))
- (c #C(0.04 0.01))
- (z (cond
- ((string= "1" fn) (mandelbrot c n z0))
- ((string= "2" fn) (mandelbrot2 c n z0))
- ((string= "3" fn) (mandelbrot3 c n z0)))))
- (complex-print z debug)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement