Re: Strange behavior of PersistentTreeMap

2010-10-23 Thread andrei
Huh! I checked several times to pass to recur replaced string, but didn't noticed that I'm passing wrong string to .replace itself. Thank you! On Oct 23, 10:12 pm, Chris Perkins wrote: > On Oct 23, 2:10 pm, andrei wrote: > > > I modified procedure a bit to see interim results, and it's output >

Re: Strange behavior of PersistentTreeMap

2010-10-23 Thread Chris Perkins
On Oct 23, 2:10 pm, andrei wrote: > I modified procedure a bit to see interim results, and it's output > confused me even more. > > (defn replace-map >   "Replaces substrings in s from (keys m) by (vals m). " >   [s m] >   (loop [cur-str s, ks (keys m)] >     (if (empty? ks) >       cur-str >    

Re: Strange behavior of PersistentTreeMap

2010-10-23 Thread andrei
I modified procedure a bit to see interim results, and it's output confused me even more. (defn replace-map "Replaces substrings in s from (keys m) by (vals m). " [s m] (loop [cur-str s, ks (keys m)] (if (empty? ks) cur-str (let [replaced (.replace s (first ks) (m (first ks))

Strange behavior of PersistentTreeMap

2010-10-22 Thread andrei
My purpose is to write function for replacing multiple substrings in a string. Here's my approach: (defn replace-map "Replaces substrings in s from (keys m) by (vals m). " [s m] (loop [cur-str s, rps m] (if (empty? rps) cur-str (recur (.replace s (first (first rps)) (second (