You are viewing a single comment's thread from:

RE: Complex numbers in clojure

I haven't used the Boost libraries at all, been out of the C++ ecosystem for a while now.

Complex numbers are super useful for physics stuff and also for optimisation. I just implemented it as a practice exercise, would be really surprised if there isn't a library for complex numbers already existing in Clojure.

One really cool feature in Clojure is the symbolic representation of rational numbers:

(/ 1 3)

evaluates to 1/3 rather than 0.3333. This allows more precise calculations, as rounding only needs to be done at the end.

Posted Using LeoFinance Beta

Sort:  

Oh wow. If you write 0.20, it will be a repeated decimal in Clojure, won't it? So instead you could handle 0.2 by writing (/ 1 5).

Yes exactly. 0.2 would be of type double and 1/5 is called "ratio" type in Clojure.

Posted Using LeoFinance Beta