;;AUTOLOAD: cond
;;AUTODOC: cond "multi-case conditional test"
"(cond ( test {form} * ) * )

This function evaluates in progn fashion the forms that are asso-
ciated with the first test that returns a true condition.

The function returns the evaluation of the last of these forms. If 
no forms are present, then the single (and necessarily non null) 
value of the test is returned. When every test produces nil, the 
cond function returns nil.

(defun fib (n)
 (cond 
	((= n 0) 1)
	((= n 1) 1)	
	(t (+ 	(fib (- n 1))
		(fib (- n 2))))))

NOTE: For efficiency, use if (see page 22) rather than cond.
"

(defunq cond (&rest cond:args &aux 
    (cond:body (copy ())) 
    cond:tmp
  )
  (dolist (cond:arg cond:args)
    (lappend cond:body (getn cond:arg 0))
    (if (> (length cond:arg) 2) 
      (lappend cond:body (+ '(progn) (subseq cond:arg 1)))
      (= (length cond:arg) 2)
      (lappend cond:body (get cond:arg 1))
      (progn
	(put cond:body (- (length cond:body) 1) 
	  (list 'setq 'cond:tmp (getn cond:arg 0))
	)
	(lappend cond:body 'cond:tmp)
      )
  ))
  (apply if cond:body)
)
  
