funny (?) str behavior

12 views
Skip to first unread message

Alfred Tarski

unread,
Feb 23, 2010, 3:47:42 AM2/23/10
to Clojure
Hi,

I have this function:

(defn wrap [x]
(str "%" x "%"))

and I do

bf=> (str "boo hoo " (map wrap ["fdfd" "ggfs"]))
"boo hoo clojure.lang.LazySeq@9e050eb0"

This looks odd to me, but if the powers that be consider this to be
the right behavior of str then my question is: what do I need to do do
get what I want?

-AT


Meikel Brandmeyer

unread,
Feb 23, 2010, 7:23:21 AM2/23/10
to Clojure
Hi,

Use apply: (apply str "boo hoo " (map wrap ["fdfd" "ggfs"])).

Sincerely
Meikel

Kevin Downey

unread,
Feb 23, 2010, 11:07:40 PM2/23/10
to clo...@googlegroups.com
pr-str

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

--
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

Jarkko Oranen

unread,
Feb 24, 2010, 3:45:55 AM2/24/10
to Clojure

if you really want the seq to be stringified instead of the elements,
just do (str "boo hoo " (seq (map (wrap [...]))))

I suppose lazy seqs are so lazy they won't even bother to provide a
string representation of themselves without coercion :)

Reply all
Reply to author
Forward
0 new messages