I scratched my itch with...
(defn map-replace [m text]
(reduce
(fn [acc [k v]] (s/replace acc (str k) (str v)))
text m))
Hope it helps.
On Tuesday, April 23, 2013 5:55:51 AM UTC+1, Mond Ray wrote:
>
> Man - you guys are good and *fast*.
>
> I was pootling around with a version that would directly replace
> "/a/:key/b" {:key "value"} with "/a/value/b" and a failed version sneaked
> into my code.
>
> Incidentally that is my only slight complaint about the code as it stands:
> I have to use something like
>
> (def url (replace-map "https://google.$tld" {:$tld "com"}))
>
> rather than the more elegant and seemingly idiomatic
>
> (def url (replace-map "https://google.:tld" {:tld "com"}))
>
> Since I am struggling to win this small battle, do you guys have any ideas
> (including that its not a good idea!)?
>
> Cheers
>
> Ray
>
> On Monday, 22 April 2013 23:19:16 UTC+2, Sean Corfield wrote:
>>
>> On Mon, Apr 22, 2013 at 1:45 PM, Mond Ray <[email protected]> wrote:
>> > Something very odd going on here - one day it works the next day it
>> fails :(
>>
>> This code is different to what you posted the other day...
>>
>> > #_=> (map #(java.util.regex.Pattern/quote (keyword %)))
>>
>> That won't work - Pattern/quote will not accept a keyword (which is
>> what the exception is telling you). In the code you posted before,
>> which did work, you had (name %) instead which would yield a String
>> from either a keyword or a string - which is clearly what you want
>> here.
>> --
>> Sean A Corfield -- (904) 302-SEAN
>> An Architect's View -- http://corfield.org/
>> World Singles, LLC. -- http://worldsingles.com/
>>
>> "Perfection is the enemy of the good."
>> -- Gustave Flaubert, French realist novelist (1821-1880)
>>
>
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.