Thanks Josef, but could you explain a bit more. Are you saying that the operation of replacing a substring (by index & length) with another substring is not a common operation?
i.e. (defn replace-substring [s r start len] (str (subs s 0 start) r (subs s (+ len start)))) If so, that does suprise me. I think I can better understand guns objection on the basis that it would be a bad function for an immutable string library, since the naming suggests mutability and also that if you wanted to replace multiple substrings (which each would require several copy operations) it would be (I think?) more efficient to do it in a single expression involving multiple calls to substring, than using replace-substring. But even so, there is already the function 'replace' in clojure which also suggests mutability. However, not being from a a java background I was also quite surprised to find out that there isnt a similar function in java (http://stackoverflow.com/questions/14642978/replace-part-of-a-string-between-indexes-in-java). Im also interested in your second comment and was wondering what you mean by transient string? Thanks Andy On Wednesday, 2 April 2014 19:05:48 UTC+1, Jozef Wagner wrote: > > No. IMO this is not a common operation and should not be in core. If you > need do it a lot, you should not use java string in the first place. > > What should be included in core is a transient string, with support for > assoc!. > > Jozef > > > On Wed, Apr 2, 2014 at 7:49 PM, Andy Smith > <the4th...@googlemail.com<javascript:> > > wrote: > >> just a shame its not in the core, no? >> >> >> On Wednesday, 2 April 2014 18:06:03 UTC+1, A. Webb wrote: >>> >>> Using subs (no need for join) is the way I would go, just define >>> >>> >>> (defn replace-at [s n c] (str (subs s 0 n) c (subs s (inc n)))) >>> >>> (replace-at "hello" 1 "a") ;=> "hallo" >>> >>> and carry on. >>> >>> >>> >> -- >> 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<javascript:> >> 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 <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.