On 5 Jun 2010, at 04:09, Travis Hoffman wrote:

First off, thanks for the advice, steps and link! Secondly, the link
to my fork is:

git://github.com/travis-a-hoffman/clojure.git

Thanks, I'll look at that...

I did notice your Complex implementation in clojure-contrib, and I
especially appreciated the effort in the generalizations. I'm a total
n00b to Clojure and functional programming. From what I've read about
the intentional exclusion of reader macros (as an example) it seems
that it is in keeping with the spirit of the language to keep the
basic mathematical operations in the core of the language and to *not*
generalize it.

I agree. What's nice about Clojure is that you can have both generic and fast implementations and use the one that's best for a given project.

Also, it seems more elegant to me to be able to simply write a complex
number in a "natural" way i.e. 5+3i. I didn't see a way to do that
without modifying clojure core

No. But I wonder if "5+3i" is very natural for a language that doesn't have infix arithmetic. This notation is just a sum of a real and an imaginary number, so in Clojure I'd expect to see (+ 5 3i) instead.

I started with "Number" (b in your note), but ran into some trouble
because of a risk a loss of precision so I used BigDecimal for the
real and imaginary parts.

What trouble? If both and imginary parts are arbitrary numbers (including possibly ratios or BigDecimal), then you should never have precision problems.

Lastly my real motivation was to gain greater familiarity with the
internals and this seemed like an approachable place to start.

Sure. The best way to start is to try to do something!

I also took a look at Apache Commons Math:

http://commons.apache.org/math/

It seems to be quite good, unencumbered and actively developed, but I
haven't been able to (easily) find any recommendations or comparisons
of the available libraries.

Maybe the first step for a math group is to evaluate and "bless" an
appropriate library? Or, would we do better to try to develop one from
scratch?

I don't remember having looked at Apache Commons Math, but I did look at a couple of Java libraries for maths. The problem with them (from a Clojure point of view) is always the same: they are not designed for a functional language, and their APIs are too low-level.

Perhaps a good compromise would be to have a thin Clojure wrapper around a good Java library.

Konrad.

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