Sunil S Nandihalli <sunil.nandiha...@gmail.com> writes:

> http://paste.lisp.org/display/93387
>
> It uses protocols and deftype I noticed that it was an old post .. I
> could not get it to compile to try it out.. I was complaining about
> likes of trying to convert a name-space-qualified to a type name
> .. w.r.t ::Complex . I tried a  couple of things to get it working
> with out success..

> Any suggestions to improve my code or to get stuart's code compiled so
> that I can try it would be very help full.

Here's how to get Stuart's working.

1. Replace "::Complex" with "Complex" everywhere.  

2. Change (deftype Complex [r i]) to (defrecord Complex [r i]). 

3. Put a . after the Complex constructors so they look like this:

    (extend-double add Complex Complex
                   (fn [c1 c2] (Complex. (+ (:r c1) (:r c2))
                                         (+ (:i c1) (:i c2)))))

You should end up with something vaguely like this:

    https://gist.github.com/755758

-- 
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

Reply via email to