Finished Koan 18

This commit is contained in:
Matthew Davidson 2022-12-20 18:36:33 +01:00
parent ab7536f8da
commit a57ebfee96
2 changed files with 8 additions and 8 deletions

File diff suppressed because one or more lines are too long

View file

@ -4,22 +4,22 @@
(meditations
"Wrap a quote around a list to suppress evaluation"
(= (quote (1 2 3 4 5)) __)
(= (quote (1 2 3 4 5)) '(1 2 3 4 5))
"There is a shortcut too!"
(= (quote __) '(1 2 3 4 5))
(= (quote (1 2 3 4 5)) '(1 2 3 4 5))
"You can quote symbols as well as lists... without evaluation!"
(= __ (let [age 9] (quote age)))
(= 'age (let [age 9] (quote age)))
"You can use a literal list as a data collection without having Clojure try to call a function"
(= (cons 1 (__ (2 3))) (list 1 2 3) (cons 1 [2 3]))
(= (cons 1 (quote (2 3))) (list 1 2 3) (cons 1 [2 3]))
"The quote affects all of its arguments, not just the top level"
(= (list 1 __) '(1 (+ 2 3)))
(= (list 1 '(+ 2 3)) '(1 (+ 2 3)))
"Syntax-quote (`) acts similarly to the normal quote"
(= (list __ __ __) `(1 2 3) '(1 2 3))
(= (list 1 2 3) `(1 2 3) '(1 2 3))
"Unquote (~) within a syntax-quoted expression lets you mark specific expressions as requiring evaluation"
(= (list __ __) `(1 ~(+ 2 3)) '(1 5)))
(= (list 1 5) `(1 ~(+ 2 3)) '(1 5)))