Skip to content

Instantly share code, notes, and snippets.

@johnwalker
Last active August 29, 2015 14:07
Show Gist options
  • Save johnwalker/750ad582d50dd3f2e09e to your computer and use it in GitHub Desktop.
Save johnwalker/750ad582d50dd3f2e09e to your computer and use it in GitHub Desktop.
(ns say-hello)
(defn say-hello
([names] (say-hello names #{}))
([names saluted]
(reduce (fn [saluted name]
(if-not (saluted name)
(do (println "Hello" name "!")
(conj saluted name))
(do (println "Welcome Back" name "!")
saluted)))
saluted names)
(println "Goodbye!")))
;; (say-hello ["Peter" "Pablo" "John" "Peter"])
;; =>
;; Hello Peter !
;; Hello Pablo !
;; Hello John !
;; Welcome Back Peter !
;; Goodbye!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment