Lisplings: Rustlings-style exercises for Common Lisp
70 exercises in 20 chapters, from first s-expressions to restarts, macros, CLOS, and a tiny Lisp interpreter. Each exercise ships broken with a solved twin and a hint. Includes a watch-mode runner, a plain-CL check harness, a nix flake, and verification tooling. All plain SBCL, no dependencies.
This commit is contained in:
commit
4df60ead93
172 files changed
+4403
No files matched your search
@@ -0,0 +1,24 @@
|
||||
;;; FUNCTIONS 4: MULTIPLE VALUES
|
||||
;;;
|
||||
;;; A function may return several values at once:
|
||||
;;; (values 1 2) => 1 and 2
|
||||
;;; Everything except the first value rides along, waiting for
|
||||
;;; MULTIPLE-VALUE-BIND or NTH-VALUE to pick it up. FLOOR is a
|
||||
;;; classic: (floor 10 3) returns 3 AND 1.
|
||||
|
||||
;; TODO: Return TWO values: the whole part of A/B and the rest.
|
||||
(defun divide (a b)
|
||||
(/ a b))
|
||||
|
||||
;; TODO: Return TWO values: whole minutes, and leftover seconds.
|
||||
(defun split-seconds (seconds)
|
||||
seconds)
|
||||
|
||||
;;; ------------------------------------------------------------------
|
||||
;;; 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)))
|
||||
Reference in new issue
Block a user