33 lines
905 B
Text
33 lines
905 B
Text
(defun rc-step-r (cells)
|
|
(if (endp (rest cells))
|
|
nil
|
|
(cons (if (second cells)
|
|
(xor (first cells) (third cells))
|
|
(and (first cells) (third cells)))
|
|
(rc-step-r (rest cells)))))
|
|
|
|
(defun rc-step (cells)
|
|
(cons (and (first cells) (second cells))
|
|
(rc-step-r cells)))
|
|
|
|
(defun rc-steps-r (cells n prev)
|
|
(declare (xargs :measure (nfix n)))
|
|
(if (or (zp n) (equal cells prev))
|
|
nil
|
|
(let ((new (rc-step cells)))
|
|
(cons new (rc-steps-r new (1- n) cells)))))
|
|
|
|
(defun rc-steps (cells n)
|
|
(cons cells (rc-steps-r cells n nil)))
|
|
|
|
(defun pretty-row (row)
|
|
(if (endp row)
|
|
(cw "~%")
|
|
(prog2$ (cw (if (first row) "#" "-"))
|
|
(pretty-row (rest row)))))
|
|
|
|
(defun pretty-output (out)
|
|
(if (endp out)
|
|
nil
|
|
(prog2$ (pretty-row (first out))
|
|
(pretty-output (rest out)))))
|