[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Checking one's examples...
- To: info-macl@cambridge.apple.com
- Subject: Checking one's examples...
- From: dmg@goldilocks.LCS.MIT.EDU
- Date: Wed, 06 Mar 91 12:14:27 EST
- In-reply-to: Your message of Wed, 06 Mar 91 11:06:30 -0500. <9103061606.AA01459@blaze.LCS.MIT.EDU>
Please excuse the rather careless mistakes in my previous
message. Though my comments still stand, the examples
are both erroneous.
1:
(check-type foo (and numberp (eql 0)))
should be
(check-type foo (and number (not (eql 0))))
2:
(defun fact (x)
(let ((result x))
(loop
(if (= (decf x) 1)
(return result)
(setq result (* result x))))))
;;; There's a problem with (fact 0) or (fact 1)
;;; falling through...
should be
(defun fact (x)
(check-type x (integer 0))
(if (< x 2)
1
(let ((result x))
(loop
(if (= (decf x) 1)
(return result)
(setq result (* result x)))))))