On Sat, Oct 3, 2009 at 7:23 AM, pmf wrote:
>
> And String is final, making deriving from it impossible.
>
> One way (most probably not the best way) would be to wrap it in a Var
> and attach the metadata to the Var, i.e.
>
> (def #^{:blah :foo} my-string "some string")
>
> Note that to access th
ng in this case) and have the
new class implement IObj. However, that solution requires me to
program in Java and seems like an overkill for the String class.
Is there a better & easier way to add meta-data to strings?
Sincerely,
Jung Ko
--~--~-~--~~~---~--~~
You
On Thu, Oct 1, 2009 at 1:17 PM, John Harrop wrote:
> On Thu, Oct 1, 2009 at 3:42 PM, Dragan Djuric wrote:
>>
>> I usualy cite Rich's conference paper and Stuart's book.
>>
>> @conference{hickey2008clojure,
>> title={{The Clojure programming language}},
>> author={Hickey, R.},
>> booktitle={Pr
Thank you everyone for the tip. It works great. Using s/replace
instead of re-sub makes the code much shorter and easier to read.
Thanks,
Jung Ko
On Tue, Sep 29, 2009 at 8:43 AM, Adrian Cuthbertson
wrote:
>
> I was just trying out str-utils2 when Stuart posted. Here's an example;
&
Does anyone know how I can replace a string with back-reference? I'd
like something like this:
(use clojure.contrib.str-utils)
(re-sub #"hello (\S+)" ", how are you \1?" "hello Jung")
=> "hello, how are you Jung?"
Basically I need the back reference \1 to evaluate to "Jung" in the
above case. Is
is the metadata
> (defmethod print-method ::my-book [thebook writer]
> (print-method (:book thebook) writer)) ; falls back to the string
> writer
>
> (print typed-book) ; prints 'somebook'
Thank you Mike and Jarkko for the detailed answer. It works as you described. :)
Sinc
). What
would be the equivalent thing in Clojure?
I already tried the following but it doesn't seem to work
(sorry...i've been programming Clojure for only two days):
user> (defmulti .toString class)
user> (defmethod .toString clojure.lang.PersistentStructMap [s]
(:book s)