#clojure logs

2008-04-06

13:50gomer-nycHi there
13:50gomer-nycI started learning Clojure yesterday, and loving it so far
13:50rhickey_cool
13:50gomer-nycI also don't know the Java Class Libs, so learning that also as I go (for example, Net access etc.)
13:50gomer-nycanyway, I have a clojure language question
13:51gomer-nycI have a working version of something I'm trying to achieve, but not sure whether this is the best implementation.
13:51gomer-nycRich, can I paste in the line of code and discuss?
13:52rhickey_sure
13:52gomer-nyccool; so what I'm doing is simply replacing one character with another in a string, and returning a string. Doing it like so:
13:53gomer-nyc(reduce (fn [x y] (str x y)) (replace {\space "+"} "new york, ny"))
13:54rhickey_I presume you are avoiding String.replaceAll as an exercise?
13:56gomer-nycHa! didn't want to use java lib stuff, but that would prob be better :-)
13:56rhickey_ (apply str (replace {\space "+"} "new york, ny"))
13:56rhickey_apply str is better than reduce with str
13:56gomer-nycagreed
13:57gomer-nycgreat, thanks
15:01jonathan_? why the difference on apply and reduce ?
15:05jonathan_sorry, apply will get the whole list instead of recursing as with reduce.