Julio Biason
4 years ago
1 changed files with 40 additions and 3 deletions
@ -1,5 +1,42 @@
|
||||
(ns bob) |
||||
|
||||
(defn response-for [s] ;; <- arglist goes here |
||||
;; your code goes here |
||||
) |
||||
(defn shout? |
||||
[x] |
||||
(let [filtered (filter #(Character/isLetter %) x)] |
||||
(if (empty? filtered) |
||||
false |
||||
(every? #(Character/isUpperCase %) filtered) |
||||
) |
||||
) |
||||
) |
||||
|
||||
(defn trim |
||||
[x] |
||||
(remove #(Character/isWhitespace %) x) |
||||
) |
||||
|
||||
(defn question? |
||||
[x] |
||||
(= (last (trim x)) \?) |
||||
) |
||||
|
||||
(defn silence? |
||||
[x] |
||||
(empty? (trim x)) |
||||
) |
||||
|
||||
(defn forceful-question? |
||||
[x] |
||||
(and (shout? x) (question? x)) |
||||
) |
||||
|
||||
(defn response-for |
||||
[s] |
||||
(cond |
||||
(silence? s) "Fine. Be that way!" |
||||
(forceful-question? s) "Calm down, I know what I'm doing!" |
||||
(shout? s) "Whoa, chill out!" |
||||
(question? s) "Sure." |
||||
:else "Whatever." |
||||
) |
||||
) |
||||
|
Loading…
Reference in new issue