ms.lsp

来自「基因演算法source code範例vc」· LSP 代码 · 共 66 行

LSP
66
字号
(defun MS (x y plotnum)
  (system::graph-init)
  (system::graph-clear)
  (system::graph-show)
  (let ((tx 0)(ty 0)
	(halfnum (/ plotnum 2))
	(z (complex 0 0)))
     (dotimes (i plotnum 'X-axis)
       (setf tx	(- (/ i	halfnum) 1))
	 (dotimes (j plotnum 'Y-axis)
	   (setf ty (- (/ j halfnum) 1))
	   (setf z (complex (float tx) (float ty)))
	   (let	((color	nil))
		(dotimes (k 50 'Iteration)
		   (setf z (+ (complex tx ty) (* z z)))
		   (setf color k)
		   (let	((rz (float (realpart z)))
			 (iz (float (imagpart z))))
		    (setf z (complex rz	iz))
		   ;(print `(z=,z rz=,rz iz=,iz))
		    (if	(> (+ (* rz rz)(* iz iz)) 4)
			(setf k	1000)
			()
		    )))
		(system::graph-dot (+ x	i) (+ y	j) (mod	color 15))
	      ;	(print `(i=,i j=,j color=,color))
	   )
	 )
     )
  )
  (read-char *keyboard-input*)
)

(defun MS2 (inx	iny len	plotnum)
  (system::graph-init)
  (system::graph-clear)
  (system::graph-show)
  (let ((tx 0)(ty 0)
	(z (complex 0 0)))
     (dotimes (i plotnum 'X-axis)
       (setf tx	(+ inx (* len (/ i plotnum))))
	 (dotimes (j plotnum 'Y-axis)
	   (setf ty (+ iny (* len (/ j plotnum))))
	   (setf z (complex (float tx) (float ty)))
	   (let	((color	nil))
		(dotimes (k 50 'Iteration)
		   (setf z (+ (complex tx ty) (* z z #c(1.3 3.4))))
		   (setf color k)
		   (let	((rz (float (realpart z)))
			 (iz (float (imagpart z))))
		    (setf z (complex rz	iz))
		   ;(print `(z=,z rz=,rz iz=,iz))
		    (if	(> (+ (* rz rz)(* iz iz)) 4)
			(setf k	1000)
			()
		    )))
		(system::graph-dot (+ 10 i) (+ 10 j) (mod color	15))
	      ;	(print `(i=,i j=,j color=,color))
	   )
	 )
     )
  )
  (read-char *keyboard-input*)
)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?