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,24 @@
|
||||
;;; RECURSION 5: MUTUAL RECURSION
|
||||
;;;
|
||||
;;; Two functions can take turns: each calls the other on (1- n) -
|
||||
;;; one less - until zero settles the question. LABELS defines
|
||||
;;; local functions that can see and call each other:
|
||||
;;;
|
||||
;;; (labels ((up (k) ... (down (1- k)))
|
||||
;;; (down (k) ... (up (1- k))))
|
||||
;;; (up n))
|
||||
|
||||
;; TODO: T when the whole number N is even, NIL when odd. Take
|
||||
;; turns subtracting one, inside LABELS, until zero answers.
|
||||
(defun my-evenp (n)
|
||||
(zerop n))
|
||||
|
||||
;;; ------------------------------------------------------------------
|
||||
;;; Checks. Read them - they tell you what to aim for - but leave
|
||||
;;; them unchanged.
|
||||
;;; ------------------------------------------------------------------
|
||||
|
||||
(check (my-evenp 0))
|
||||
(check (my-evenp 4))
|
||||
(check (not (my-evenp 7)))
|
||||
(check (not (my-evenp 1)))
|
||||
Reference in new issue
Block a user