Merge 6d5b226307 into 614562b053
This commit is contained in:
commit
1aa1a10d19
3 changed files with 16 additions and 18 deletions
|
|
@ -24,13 +24,13 @@
|
|||
(= __ (not (= 1 nil)))
|
||||
|
||||
"Strings, and keywords, and symbols: oh my!"
|
||||
(= __ (= "foo" :foo 'foo))
|
||||
(= __ (= "hello" :hello 'hello))
|
||||
|
||||
"Make a keyword with your keyboard"
|
||||
(= :foo (keyword __))
|
||||
(= :hello (keyword __))
|
||||
|
||||
"Symbolism is all around us"
|
||||
(= 'foo (symbol __))
|
||||
(= 'hello (symbol __))
|
||||
|
||||
"When things cannot be equal, they must be different"
|
||||
(not= :fill-in-the-blank __))
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
(ns koans.07-conditionals
|
||||
(:require [koan-engine.core :refer :all]))
|
||||
|
||||
(defn explain-defcon-level [exercise-term]
|
||||
(defn explain-exercise-velocity [exercise-term]
|
||||
(case exercise-term
|
||||
:fade-out :you-and-what-army
|
||||
:double-take :call-me-when-its-important
|
||||
:round-house :o-rly
|
||||
:fast-pace :thats-pretty-bad
|
||||
:cocked-pistol :sirens
|
||||
:say-what?))
|
||||
:bicycling "pretty fast"
|
||||
:jogging "not super fast"
|
||||
:walking "not fast at all"
|
||||
"is that even exercise?"))
|
||||
|
||||
(meditations
|
||||
"You will face many decisions"
|
||||
|
|
@ -40,10 +38,10 @@
|
|||
'doom
|
||||
'more-doom))
|
||||
|
||||
"In case of emergency, sound the alarms"
|
||||
(= :sirens
|
||||
(explain-defcon-level __))
|
||||
"In case of emergency, go fast"
|
||||
(= "pretty fast"
|
||||
(explain-exercise-velocity __))
|
||||
|
||||
"But admit it when you don't know what to do"
|
||||
(= __
|
||||
(explain-defcon-level :yo-mama)))
|
||||
(explain-exercise-velocity :watching-tv)))
|
||||
|
|
|
|||
|
|
@ -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}])))
|
||||
|
|
|
|||
Loading…
Reference in a new issue