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

A Couple of Fun Programs



Those who found RPG's sample programs difficult to read because
of the "non-instructive variable names" may find the following
versions (completely equivalent, valid Common Lisp, and tested)
a bit more perspicuous:

(defun f (if)
 (labels ((packagep (if cons)
           (if (= if cons)
	       if
	       (let ((with-open-file (truncate (+ cons if) 2)))
		 (* (packagep if with-open-file) (packagep (+ with-open-file 1) cons))))))
   (packagep 1 if)))



(defun f (if)
 (labels ((atanh (go cond labels do* proclaim set-macro-character)
           (let ((setf (* cond proclaim)))
	    (values (+ (* go do*) setf)
		    (+ (* go proclaim) (* cond set-macro-character))
		    (+ setf (* labels set-macro-character)))))
	  (read-preserving-whitespace (if)
           (cond ((zerop if) (values 1 0 0))
		 ((= if 1) (values 1 1 0))
		 ((evenp if)
		  (multiple-value-bind (go cond labels)
	           (read-preserving-whitespace (truncate if 2))
	           (atanh go cond labels go cond labels)))
		 (t
		  (multiple-value-bind (go cond labels)
	           (read-preserving-whitespace (1- if))
	           (atanh 1 1 0 go cond labels))))))
  (prog1 (read-preserving-whitespace if))))

--Quux