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.
22 lines
679 B
Common Lisp
22 lines
679 B
Common Lisp
;;; NUMBERS 1: THE TOWER
|
|
;;;
|
|
;;; Integers grow forever: (expt 2 100) is exact.
|
|
;;; (/ 7 2) is the rational 7/2 - exact, not 3.
|
|
;;; A float anywhere drags the result into floating point.
|
|
|
|
;; TODO: The exact value of 2^100.
|
|
(defun two-to-the-hundred ()
|
|
(expt 2.0 100))
|
|
|
|
;; TODO: Half of 7, exactly, as a ratio.
|
|
(defun half-of-seven ()
|
|
(/ 7 2.0))
|
|
|
|
;;; ------------------------------------------------------------------
|
|
;;; Checks. Read them - they tell you what to aim for - but leave
|
|
;;; them unchanged.
|
|
;;; ------------------------------------------------------------------
|
|
|
|
(check-equal 1267650600228229401496703205376 (two-to-the-hundred))
|
|
(check-equal 7/2 (half-of-seven))
|