Wave 4: add sequences/vectors/files chapters, 23 exercises, quiz3, finish ceremony, PCL table
This commit is contained in:
1 parent
77843402fa
commit
4675bd1106
76 files changed
+2505
-14
No files matched your search
@@ -0,0 +1,26 @@
|
||||
;;; CONDITIONALS 5: CASE AND ECASE (solution)
|
||||
|
||||
(defun rate-fruit (fruit)
|
||||
(case fruit
|
||||
((apple banana) "cheap")
|
||||
((mango durian) "pricey")
|
||||
(t "unknown")))
|
||||
|
||||
(defun door-state (state)
|
||||
(ecase state
|
||||
(:open "come in")
|
||||
(:closed "knock first")))
|
||||
|
||||
;;; ------------------------------------------------------------------
|
||||
;;; Checks. Read them - they tell you what to aim for - but leave
|
||||
;;; them unchanged.
|
||||
;;; ------------------------------------------------------------------
|
||||
|
||||
(check-equal "cheap" (rate-fruit 'apple))
|
||||
(check-equal "cheap" (rate-fruit 'banana))
|
||||
(check-equal "pricey" (rate-fruit 'mango))
|
||||
(check-equal "pricey" (rate-fruit 'durian))
|
||||
(check-equal "unknown" (rate-fruit 'kiwi))
|
||||
(check-equal "come in" (door-state :open))
|
||||
(check-equal "knock first" (door-state :closed))
|
||||
(check-error (door-state :ajar) 'type-error)
|
||||
Reference in new issue
Block a user