Re: Multiple dispatch with Multimethods

2009-12-08 Thread Meikel Brandmeyer
Hi, On Dec 8, 8:36 am, Tzach wrote: > I didn't know the costume hierarchy at all, it seems to be very > useful. > I understand it is coupled to the Java object hierarchy. Not at all. Have a look at the docstrings, eg. of derive and isa?. Even in my example ::Asteroid and ::Spaceship are not Jav

Re: Multiple dispatch with Multimethods

2009-12-07 Thread Tzach
Thanks I didn't know the costume hierarchy at all, it seems to be very useful. I understand it is coupled to the Java object hierarchy. Is there a way to create similar util for strings, as I did on my first example? On Dec 7, 12:10 pm, Meikel Brandmeyer wrote: > Hi, > > On Dec 7, 10:21 am, Tzach

Re: Multiple dispatch with Multimethods

2009-12-07 Thread Meikel Brandmeyer
Hi, On Dec 7, 10:21 am, Tzach wrote: > (defmulti collide-with foo) > > (defmethod collide-with ["asteroid" "spaceship"] (print "Boom")) > (defmethod collide-with ["asteroid" any] (print " Wiiissh")) > (defmethod collide-with [any "spaceship"] (print "Wooossh")) > (defmethod collide-with [any any

Re: Multiple dispatch with Multimethods

2009-12-07 Thread ataggart
On Dec 7, 1:21 am, Tzach wrote: > Hello > What is the idiomatic way to implement the classic collide-with > function in Clojure? > I would like to implement something similar to the following (pseudo > code ahead): > > (defmulti collide-with foo) > > (defmethod collide-with ["asteroid" "spaceshi