I'm new to Common Lisp, and found myself taking advantage of way functions returns values. The following are to two trivial examples:
(defun safe-avg (a b)
(and (numberp a) (numberp b) (/ (+ a b) 2)))
(defun safe-div (a b)
(and (numberp a) (numberp b) (> b 0) (/ a b)))
But I could've written it like this (arguably clearer):
(defun safe-avg (a b)
(if (and (numberp a) (numberp b))
(/ (+ a b) 2)))
(defun safe-div (a b)
(if (and (numberp a) (numberp b) (> b 0))
(/ a b)))
I wanted to know what is the preferred method of doing something like this and the reasoning behind it, before I start abusing this habit.