Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-10 Thread Eric Tschetter
That makes sense. On Fri, Apr 10, 2009 at 6:16 AM, Stephen C. Gilardi wrote: > > On Apr 10, 2009, at 3:55 AM, Eric Tschetter wrote: > >> Sure enough, I get the same results >> >> user=> (defn as-str >> [& args] >> (apply str (map #(if (instance? clojure.lang.Named %) (name %) %) args))) >> #'use

Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-10 Thread Stephen C. Gilardi
On Apr 10, 2009, at 3:55 AM, Eric Tschetter wrote: Sure enough, I get the same results user=> (defn as-str [& args] (apply str (map #(if (instance? clojure.lang.Named %) (name %) %) args))) #'user/as-str user=> (time (dotimes [i 100] (as-str :a))) "Elapsed time: 416.497348 msecs" nil us

Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-10 Thread Eric Tschetter
Sure enough, I get the same results user=> (defn as-str [& args] (apply str (map #(if (instance? clojure.lang.Named %) (name %) %) args))) #'user/as-str user=> (time (dotimes [i 100] (as-str :a))) "Elapsed time: 416.497348 msecs" nil user=> (time (dotimes [i 100] (as-str :a 1))) "Elapse

Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-09 Thread Meikel Brandmeyer
Hi, Am 09.04.2009 um 15:49 schrieb Stephen C. Gilardi: I like it for its simplicity. It can actually be a little simpler yet as the general case gives the same result when passed no arguments as the special case does: (defn as-str [& args] (apply str (map #(if (instance? clojure.lang.Nam

Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-09 Thread Stephen C. Gilardi
On Apr 9, 2009, at 2:57 AM, Eric Tschetter wrote: Might I suggest (defn as-str ([] "") ([& args] (apply str (map #(if (instance? clojure.lang.Named %) (name %) %) args))) I like it for its simplicity. It can actually be a little simpler yet as the general case gives the same result

Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-09 Thread Paul Stadig
I think it makes sense for (str) to return "", but I'm not sure about (as-str) being "". It doesn't seem as obvious and expected to me. Paul On Thu, Apr 9, 2009 at 2:57 AM, Eric Tschetter wrote: > > Might I suggest > > (defn as-str > ([] "") > ([& args] >(apply str (map #(if (instance? c

Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-08 Thread Eric Tschetter
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 wrote: > > On Apr 8, 2009, at 8:13 PM, Stuart Halloway wrote: > >> Changed to as-str (r654). > >

Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-08 Thread Stephen C. Gilardi
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 nam