#clojure log - Apr 06 2008

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

13:50 gomer-nyc: Hi there

13:50 I started learning Clojure yesterday, and loving it so far

13:50 rhickey_: cool

13:50 gomer-nyc: I also don't know the Java Class Libs, so learning that also as I go (for example, Net access etc.)

13:50 anyway, I have a clojure language question

13:51 I have a working version of something I'm trying to achieve, but not sure whether this is the best implementation.

13:51 Rich, can I paste in the line of code and discuss?

13:52 rhickey_: sure

13:52 gomer-nyc: cool; so what I'm doing is simply replacing one character with another in a string, and returning a string. Doing it like so:

13:53 (reduce (fn [x y] (str x y)) (replace {\space "+"} "new york, ny"))

13:54 rhickey_: I presume you are avoiding String.replaceAll as an exercise?

13:56 gomer-nyc: Ha! didn't want to use java lib stuff, but that would prob be better :-)

13:56 rhickey_: (apply str (replace {\space "+"} "new york, ny"))

13:56 apply str is better than reduce with str

13:56 gomer-nyc: agreed

13:57 great, thanks

15:01 jonathan_: ? why the difference on apply and reduce ?

15:05 sorry, apply will get the whole list instead of recursing as with reduce.

Logging service provided by n01se.net