forked from functional-koans/clojure-koans
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Covers - quote - syntax-quote - unquote
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(ns koans.24-quote | ||
(:require [koan-engine.core :refer :all])) | ||
|
||
|
||
(meditations | ||
"use quote to express a list" | ||
(= (quote __) (list 1 2 3 4 5)) | ||
|
||
"Clojure provide a shotcut" | ||
(= (quote __) '(1 2 3 4 5)) | ||
|
||
"The quote special operator prevents its argument from being evaluated at all" | ||
(= __ (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])) | ||
|
||
"Th quote affects all of its argument, not just the top level" | ||
(= (list 1 __) '(1 (+ 2 3))) | ||
|
||
"Syntax-quote has a few extra features that make it ideal for constructing collections to be used as code." | ||
(= (list __ __ __) `(1 2 3) '(1 2 3)) | ||
|
||
"Unquote is used to demarcate specific forms as requiring evaluation by prefixing fhem with the symbol ~ within the body of a syntax-quote" | ||
(= (list __ __) `(1 ~(+ 2 3)) '(1 5)) | ||
) |