Skip to content

Instantly share code, notes, and snippets.

@Jpatcourtney
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jpatcourtney/20953b6117952f92a5da to your computer and use it in GitHub Desktop.
Save Jpatcourtney/20953b6117952f92a5da to your computer and use it in GitHub Desktop.
(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