24 lines
730 B
Common Lisp
24 lines
730 B
Common Lisp
;;; CONDITIONALS 1: IF
|
|
;;;
|
|
;;; (if condition then-form else-form)
|
|
;;;
|
|
;;; Exactly one then, at most one else. And the golden rule: NIL is
|
|
;;; the only false value. Zero, the empty string, everything else:
|
|
;;; all TRUE.
|
|
|
|
;; TODO: "hot" above 30 degrees, "pleasant" otherwise.
|
|
(defun classify (temperature)
|
|
(if temperature
|
|
"hot"
|
|
"pleasant"))
|
|
|
|
;;; ------------------------------------------------------------------
|
|
;;; Checks. Read them - they tell you what to aim for - but leave
|
|
;;; them unchanged.
|
|
;;; ------------------------------------------------------------------
|
|
|
|
(check-equal "hot" (classify 35))
|
|
(check-equal "pleasant" (classify 20))
|
|
(check-equal "hot" (classify 31))
|
|
(check-equal "pleasant" (classify 30))
|