Last active
August 29, 2015 14:07
-
-
Save johnwalker/750ad582d50dd3f2e09e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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