Might I suggest

(defn as-str
  ([] "")
  ([& args]
    (apply str (map #(if (instance? clojure.lang.Named %) (name %) %) args)))

--Eric Tschetter

On Wed, Apr 8, 2009 at 8:19 PM, Stephen C. Gilardi <squee...@mac.com> wrote:
>
> On Apr 8, 2009, at 8:13 PM, Stuart Halloway wrote:
>
>> Changed to as-str (r654).
>
> Very nice!
>
> Should we extend as-str to any number of arguments like its close cousin
> str?
>
> Here's a proposed implementation:
>
> (defn as-str
>  "With no args, returns the empty string. With one arg, returns its name
>  or string representation. (as-str nil) returns the empty string. With
>  more than one arg, returns the concatenation of the as-str values of the
>  args."
>  {:tag String}
>  ([] "")
>  ([x]
>     (if (instance? clojure.lang.Named x)
>       (name x)
>       (str x)))
>  ([x & ys]
>     (let [sb (StringBuilder. #^String (as-str x))]
>       (doseq [y ys]
>         (.append sb (as-str y)))
>       (.toString sb))))
>
> Comments welcome.
>
> --Steve
>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to