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,28 @@
|
||||
;;; FUNCTIONS 5: PRODUCING VALUES
|
||||
;;;
|
||||
;;; FUNCTIONS 4 let values ride along by passing FLOOR through. This
|
||||
;;; time you MAKE them: (values a b) returns two values at once.
|
||||
;;;
|
||||
;;; MOD gives a remainder: (mod 265 100) => 65. FLOOR gives the
|
||||
;;; whole part: (floor 265 100) => 2.
|
||||
;;;
|
||||
;;; The checks gather the values with MULTIPLE-VALUE-LIST again.
|
||||
|
||||
;; TODO: CENTS as two values: whole DOLLARS and leftover cents.
|
||||
(defun split-money (cents)
|
||||
(list (floor cents 100) (mod cents 100)))
|
||||
|
||||
;; TODO: N as two values: half of it, and double it. (/ 7 2) is the
|
||||
;; exact rational 7/2 - fine.
|
||||
(defun half-and-double (n)
|
||||
(* n 2))
|
||||
|
||||
;;; ------------------------------------------------------------------
|
||||
;;; Checks. Read them - they tell you what to aim for - but leave
|
||||
;;; them unchanged.
|
||||
;;; ------------------------------------------------------------------
|
||||
|
||||
(check-equal '(2 65) (multiple-value-list (split-money 265)))
|
||||
(check-equal '(0 5) (multiple-value-list (split-money 5)))
|
||||
(check-equal '(3 12) (multiple-value-list (half-and-double 6)))
|
||||
(check-equal '(7/2 14) (multiple-value-list (half-and-double 7)))
|
||||
Reference in new issue
Block a user