learning koans

- refreshed understanding of lexical vs. dynamic binding
  https://gigamonkeys.com/book/variables.html
- was taught CASE as simpler variant of COND
This commit is contained in:
efim
2022-07-24 13:18:22 +00:00
parent 49c00c24ee
commit fd03924c10
7 changed files with 116 additions and 110 deletions

View File

@@ -28,38 +28,38 @@
;;; Sometimes, you will be asked to provide values that are equal to something.
(define-test fill-in-the-blanks
(assert-equal ____ 2)
(assert-equal ____ 3.14)
(assert-equal ____ "Hello World"))
(assert-equal 2 2)
(assert-equal 3.14 3.14)
(assert-equal "Hello World" "Hello World"))
;;; Sometimes, you will be asked to say whether something is true or false,
;;; In Common Lisp, the canonical values for truth and falsehood are T and NIL.
(define-test assert-true
(assert-true ____))
(assert-true t))
(define-test assert-false
(assert-false ____))
(assert-false nil))
;; could use C-x C-e (sly-eval-last-expression) to eval just (= 34 34) to check whether T or NIL returns
(define-test true-or-false
(true-or-false? ____ (= 34 34))
(true-or-false? ____ (= 19 78)))
(true-or-false? t (= 34 34))
(true-or-false? nil (= 19 78)))
;;; Since T and NIL are symbols, you can type them in lowercase or uppercase;
;;; by default, Common Lisp will automatically upcase them upon reading.
(define-test upcase-downcase
;; Try inserting a lowercase t here.
(assert-equal ____ T)
(assert-equal t T)
;; Try inserting an uppercase NIL here.
(assert-equal ____ nil))
(assert-equal NIL nil))
;;; Sometimes, you will be asked to provide a part of an expression that must be
;;; either true or false.
(define-test a-true-assertion
(assert-true (= ____ (+ 2 2))))
(assert-true (= 4 (+ 2 2))))
(define-test a-false-assertion
(assert-false (= ____ (+ 2 2))))
(assert-false (= 3 (+ 2 2))))