Files
lisplings/solutions/02_functions/functions4.lisp
T

20 lines
639 B
Common Lisp

;;; FUNCTIONS 4: MULTIPLE VALUES (solution)
;;;
;;; The checks below gather the values with MULTIPLE-VALUE-LIST,
;;; turning them into a list.
(defun divide (a b)
(floor a b))
(defun split-seconds (seconds)
(floor seconds 60))
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check-equal '(3 1) (multiple-value-list (divide 10 3)))
(check-equal '(3 1) (multiple-value-list (divide 7 2)))
(check-equal '(2 5) (multiple-value-list (split-seconds 125)))