Last active
August 29, 2015 14:02
-
-
Save Jpatcourtney/20953b6117952f92a5da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns bob) | |
(defn is-all-caps | |
[input] | |
(= input (clojure.string/upper-case input))) | |
(is-all-caps "SOME STRING") | |
(defn ends-in-question-mark | |
[input] | |
(= (last input) \?)) | |
(ends-in-question-mark "John?") | |
(ends-in-question-mark "Jordan?") | |
(defn no-characters | |
[input] | |
(= "" (clojure.string/trim input))) | |
(no-characters " ") | |
(defn no-letters | |
[input] | |
(= (clojure.string/upper-case input) (clojure.string/lower-case input))) | |
(no-letters "12, 3!") | |
(defn response-for | |
[input] | |
(cond | |
(no-characters input) "Fine. Be that way!" | |
(and(is-all-caps input)(false?(no-letters input))) "Woah, chill out!" | |
(ends-in-question-mark input) "Sure." | |
(no-letters input) "Whatever." | |
:else "Whatever.")) | |
(response-for "WHAT THE HELL?") | |
(= "Whatever." (response-for "Tom-ay-to, tom-aaaah-to.")) | |
(= "Woah, chill out!"(response-for "WATCH OUT!")) | |
(= "Sure."(response-for "Does this cryogenic chamber make me look fat?")) | |
(= "Whatever."(response-for "Let's go make out behind the gym!")) | |
(= "Whatever."(response-for "It's OK if you don't want to go to the DMV.")) | |
(= "Woah, chill out!"(response-for "WHAT THE HELL WERE YOU THINKING?")) | |
(= "Woah, chill out!"(response-for "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")) | |
(= "Woah, chill out!"(response-for "1, 2, 3 GO!")) | |
(= "Woah, chill out!"(response-for "I HATE YOU")) | |
(= "Whatever."(response-for "Ending with ? means a question.")) | |
(= "Fine. Be that way!"(response-for "")) | |
(= "Fine. Be that way!"(response-for " ")) | |
(= "Whatever."(response-for "1, 2, 3")) | |
(= "Sure."(response-for "4?")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment