You could write it:

(defn say-hello
  ([names] (say-hello names #{}))
  ([[name & names] saluted]
    (if name
      (do (if (saluted name)
            (println "Welcome back" name)
            (println "Hello" name))
          (recur names (conj saluted name)))
      (println "Goodbye"))))

- James

On 2 October 2014 00:06, Nicolás F. <[email protected]> wrote:

> I'm a clojure noob and im playing around with the language; made this fn
> to have a taste of a couple of features. I think it's pretty concise but
> i'm probably doing something "not the clojure way", So if you can teach me
> a couple of things please go ahead ;D
>
> (defn say_hello
>   ([names] (say_hello names []))
>   ([names saluted]
>     (if (some #{(first names)} saluted)
>       (println "Welcome Back" (first names) "!")
>       (println "Hello" (first names) "!"))
>     (if (empty? (rest names))
>       (println "Goodbye")
>       (say_hello (rest names) (cons (first names) saluted)))))
>
> (say_hello ["Peter" "Pablo" "John" "Peter"])
>
> ; Hello Peter !
> ; Hello Pablo !
> ; Hello John !
> ; Welcome Back Peter !
> ; Goodbye
> ; nil
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to