From 6d5b2263074e5fdc2e0c502a236d011350711577 Mon Sep 17 00:00:00 2001 From: Tom Marble Date: Sun, 14 Jun 2015 21:06:04 -0500 Subject: [PATCH 1/2] attempt to make koans more inclusive --- src/koans/21_group_by.clj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/koans/21_group_by.clj b/src/koans/21_group_by.clj index 1e845d5..e7a0408 100644 --- a/src/koans/21_group_by.clj +++ b/src/koans/21_group_by.clj @@ -19,20 +19,20 @@ "You can also group by a primary key" (= __ (group-by :id [{:id 1 :name "Bob"} - {:id 2 :name "Mike"} + {:id 2 :name "Jennifer"} {:id 1 :last-name "Smith"} ])) "But be careful when you group by non-required key" (= {"Bob" [{:name "Bob" :id 1}] - "Mike" [{:name "Mike" :id 2}] + "Jennifer" [{:name "Jennifer" :id 2}] __ [{:last-name "Smith" :id 1}]} (group-by :name [{:id 1 :name "Bob"} - {:id 2 :name "Mike"} + {:id 2 :name "Jennifer"} {:id 1 :last-name "Smith"}])) "The true power of group-by comes with custom functions" (= __ (group-by #(if (:bad %) :naughty-list :nice-list) [{:name "Jimmy" :bad true} - {:name "Jack" :bad false} + {:name "Anna" :bad false} {:name "Joe" :bad true}]))) From 54d4b1a9993bfc3674a13c9459dfe435cccc4a66 Mon Sep 17 00:00:00 2001 From: Tom Marble Date: Sun, 14 Jun 2015 21:38:41 -0500 Subject: [PATCH 2/2] refer to clojure.set in 04 --- src/koans/04_sets.clj | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/koans/04_sets.clj b/src/koans/04_sets.clj index 0b5d14e..d6b4063 100644 --- a/src/koans/04_sets.clj +++ b/src/koans/04_sets.clj @@ -1,5 +1,6 @@ (ns koans.04-sets - (:require [koan-engine.core :refer :all])) + (:require [koan-engine.core :refer :all] + [clojure.set :as set])) (meditations "You can create a set by converting another collection" @@ -12,10 +13,10 @@ (= __ (set '(1 1 2 2 3 3 4 4 5 5))) "You can ask clojure for the union of two sets" - (= __ (clojure.set/union #{1 2 3 4} #{2 3 5})) + (= __ (set/union #{1 2 3 4} #{2 3 5})) "And also the intersection" - (= __ (clojure.set/intersection #{1 2 3 4} #{2 3 5})) + (= __ (set/intersection #{1 2 3 4} #{2 3 5})) "But don't forget about the difference" - (= __ (clojure.set/difference #{1 2 3 4 5} #{2 3 5}))) + (= __ (set/difference #{1 2 3 4 5} #{2 3 5})))