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
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
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
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
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
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
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).
>
>
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