From 28bf698566dd207cb1dafdb86154af2a5f685cab Mon Sep 17 00:00:00 2001 From: Micah Martin and Colin Jones Date: Mon, 4 Mar 2013 17:30:00 -0600 Subject: [PATCH] Clarify keywords, symbols, maps, sets --- ideaboard.txt | 3 +++ resources/koans.clj | 8 +++++--- src/koans/01_equalities.clj | 9 +++++++++ src/koans/04_sets.clj | 8 ++++---- src/koans/05_maps.clj | 9 +++------ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/ideaboard.txt b/ideaboard.txt index b30f6d5..383bebf 100644 --- a/ideaboard.txt +++ b/ideaboard.txt @@ -1,5 +1,8 @@ Concepts / Language Features ===== + +Quoting + new record syntax Agents Vars diff --git a/resources/koans.clj b/resources/koans.clj index 37efc6b..bb05dcf 100644 --- a/resources/koans.clj +++ b/resources/koans.clj @@ -5,6 +5,9 @@ false true true + false + "foo" + "foo" 3]}] ["02_lists" {"__" [1 2 3 4 5 @@ -31,15 +34,14 @@ [:butter :and] 3]}] - ["04_sets" {"__" [nil + ["04_sets" {"__" [[3] 3 #{1 2 3 4 5} #{1 2 3 4 5} #{2 3} #{1 4}]}] - ["05_maps" {"__" [{} - 0 + ["05_maps" {"__" [:b 2 1 2 2 diff --git a/src/koans/01_equalities.clj b/src/koans/01_equalities.clj index d36e8cd..aead9f8 100644 --- a/src/koans/01_equalities.clj +++ b/src/koans/01_equalities.clj @@ -20,5 +20,14 @@ "Something is not equal to nothing" (= __ (not (= 1 nil))) + "Strings, and keywords, and symbols: oh my!" + (= __ (= "foo" :foo 'foo)) + + "Make a keyword with your keyboard" + (= :foo (keyword __)) + + "Symbolism is all around us" + (= 'foo (symbol __)) + "When things cannot be equal, they must be different" (not= :fill-in-the-blank __)) diff --git a/src/koans/04_sets.clj b/src/koans/04_sets.clj index d8c60a4..256bd47 100644 --- a/src/koans/04_sets.clj +++ b/src/koans/04_sets.clj @@ -1,11 +1,11 @@ (meditations - "You can create a set in two ways" - (= #{} (set __)) + "You can create a set by converting another collection" + (= #{3} (set __)) - "They are another important data structure in clojure" + "Counting them is like counting other collections" (= __ (count #{1 2 3})) - "Remember that a set is a 'set'" + "Remember that a set is a *mathematical* set" (= __ (set '(1 1 2 2 3 3 4 4 5 5))) "You can ask clojure for the union of two sets" diff --git a/src/koans/05_maps.clj b/src/koans/05_maps.clj index c0cc7a6..6fe601a 100644 --- a/src/koans/05_maps.clj +++ b/src/koans/05_maps.clj @@ -1,9 +1,6 @@ (meditations - "There are two ways to create maps" - (= __ (hash-map)) - - "Maps in clojure associate keys with values" - (= __ (count (hash-map))) + "Don't get lost when creating a map" + (= {:a 1 :b 2} (hash-map :a 1 __ __)) "A value must be supplied for each key" (= {:a 1} (hash-map :a __)) @@ -14,7 +11,7 @@ "You can look up the value for a given key" (= __ (get {:a 1 :b 2} :b)) - "Maps can be used as lookup functions" + "Maps can be used as functions to do lookups" (= __ ({:a 1 :b 2} :a)) "And so can keywords"