Re: Math as multimethods

2008-12-08 Thread ppierre
On 8 déc, 23:13, "Michael Reid" <[EMAIL PROTECTED]> wrote: > Then I of course write the implementations for various different > types. Then, because the multi-method names don't look nice, I wrote a > macro which transformed the regular operators into calls on the > multi-methods, i.e.: > >  (macr

Re: Math as multimethods

2008-12-08 Thread Michael Reid
I've been toying with something similar. The approach I took was to define multi-methods for the various operators: (defmulti add class) (defmulti sub class) (defmulti mul class) (defmulti div class) ... Then I of course write the implementations for various different types. Then, because the m

Re: Math as multimethods

2008-12-08 Thread ppierre
On 8 déc, 17:14, Mark Fredrickson <[EMAIL PROTECTED]> wrote: > >> Alternatively, could I provide a "multi- > >> math" lib to redefine the core math functions? > > > Type classes would be king. > > Do you mean this in the Haskell sense? Yes : http://www.haskell.org/tutorial/classes.html Haskell ma

Re: Math as multimethods

2008-12-08 Thread Mark Fredrickson
> >> Alternatively, could I provide a "multi- >> math" lib to redefine the core math functions? > > Type classes would be king. Do you mean this in the Haskell sense? (I'm not too familiar with those) Or something more like Java's types? I was thinking about how to solve this problem more gen

Re: Math as multimethods

2008-12-06 Thread ppierre
On 6 déc, 05:09, Mark Fredrickson <[EMAIL PROTECTED]> wrote: > Alternatively, could I provide a "multi- > math" lib to redefine the core math functions? Type classes would be king. But at least you can use your definition : (ns test.test (:refer-clojure :exclude [+ -])) (defn + [a b] 33

Math as multimethods

2008-12-06 Thread Mark Fredrickson
Hello, Clojure newbie here. I'm porting a small Scheme matrix/linear algebra library over to Clojure as a way to get familiar. In my scheme lib, I have a (matrix-mult A B) function, but it would be nice to have the more standard notation (* A B) or (* 3 A) for scalar multiplication. I see *, /,