Meikel & Chouser -

Thanks for your help.  That does it.  I clearly haven't quite grokked
the
namespace stuff in clojure yet.  Better get on that....

Shel


On Oct 21, 1:18 pm, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> Am 21.10.2009 um 20:49 schrieb Shel:
>
> > (defmulti area (fn [s m] [(:shape s) (:measure m)]))
> > (defmethod area[:rectangle :side] [s m] (* (:side m) (:side m)))
> > (defmethod area[:rectangle :sides] [s m] (* (:side1 m) (:side2 m)))
> > (derive ::square ::rectangle)
> > user=> (area {:shape :square} {:measure :side :side 2})
>
> You have to use ::square and ::rectangle in the multimethod and the  
> maps as you did in the derive.
>
> (defmulti area (fn [s m] [(:shape s) (:measure m)]))
> (defmethod area[::rectangle ::side] [s m] (* (:side m) (:side m)))
> (defmethod area[::rectangle ::sides] [s m] (* (:side1 m) (:side2 m)))
> (derive ::square ::rectangle)
> (area {:shape ::square} {:measure ::side :side 2})
>
> This should do the trick.
>
> Sincerely
> Meikel
>
>  smime.p7s
> 3KViewDownload

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