Files
lisplings/exercises/04_conditionals/if1.lisp
T
venomade 6e2c382c78 Fix 16 mid-chapter exercise defects (scouts mid1+mid2)
Verified: dev/verify.sh all 70 exercises green (broken fail, solved pass).
2026-11-22 04:52:35 +00:00

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