Skip to content

Instantly share code, notes, and snippets.

@tbl3rd
Last active August 29, 2015 14:15
Show Gist options
  • Save tbl3rd/d1f38ee456c939d236a5 to your computer and use it in GitHub Desktop.
Save tbl3rd/d1f38ee456c939d236a5 to your computer and use it in GitHub Desktop.
difficult
(ns responder.core
(:import [com.google.common.collect ImmutableMap$Builder]))
(def responses
(letfn [(+ [& lines] (clojure.string/join " " lines))]
(-> (new ImmutableMap$Builder)
(. put "weather" (+ "There is an 80% chance of rain this afternoon."
"The high will be 8 and the low 2."))
(. put "window" "Sensors indicate that all windows are closed.")
(. put "heat" "Your thermostat is currently set to 20.")
(. put "thermostat" "Setting thermostat to 15.")
(. put "oven" "Do not worry. Your oven is off.")
(. put "walked" "You walked 1.3 kilometers so far.")
(. put "week" (+ "You are doing great!"
"Walk another half kilometer,"
"and you will meet your goal for the week."))
(. put "help" "Sending help to your location now.")
(. build))))
(defn respond-to
[request sorry]
(or (. responses get request) sorry))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment