Skip to content

Commit

Permalink
Clarify keywords, symbols, maps, sets
Browse files Browse the repository at this point in the history
  • Loading branch information
Micah Martin and Colin Jones committed Mar 4, 2013
1 parent d275ab8 commit 28bf698
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
3 changes: 3 additions & 0 deletions ideaboard.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Concepts / Language Features
=====

Quoting

new record syntax
Agents
Vars
Expand Down
8 changes: 5 additions & 3 deletions resources/koans.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
false
true
true
false
"foo"
"foo"
3]}]

["02_lists" {"__" [1 2 3 4 5
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/koans/01_equalities.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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 __))
8 changes: 4 additions & 4 deletions src/koans/04_sets.clj
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
9 changes: 3 additions & 6 deletions src/koans/05_maps.clj
Original file line number Diff line number Diff line change
@@ -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 __))
Expand All @@ -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"
Expand Down

0 comments on commit 28bf698

Please sign in to comment.