Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print a list as a string without parentheses

I did:

user=> (println (for [line (range 1 5)] (str "line=" line)))

and got:

(line=1 line=2 line=3 line=4)

but I wanted only line=1 line=2 line=3 line=4 as a string. How do I do this?

like image 707
juise Avatar asked Sep 21 '12 17:09

juise


1 Answers

You need 'apply'.

(apply println (for [line (range 1 5)] (str "line=" line)))

Alternatively,

(println (apply str (interpose " " (map #(str "line=" %) (range 1 5)))))
like image 149
JohnJ Avatar answered Sep 20 '22 17:09

JohnJ