[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking one's examples...



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)))))))