On 15 Dec 2009, at 14:07, Robert Poor wrote:
You've forced my hand. Would you be interested in a rational number package (y'know, where numbers are represented as a fraction)? I wrote one "by accident" when I thought that roundoff was causing a problem. It wasn't, but I have a cleanly written and tested Rational class if anyone could use it.
Comes with a test suite. Has a stable float-to-rational conversion algorithm where you get to specify the maximum denominator. It even has a to_string() routine.
If someone tells me where to put the code, I'm happy to send it.
I do not have need for such a class right now, as I just play the intervals, and therefore floats are just fine. Though I have written Haskell code for computing continued fraction convergents, which is very useful for analyzing data, which I use in Hugs. So rational numbers are useful - I just don't use them in ChucK, right now. But you bring up a question of where to put the stuff. Putting it up on this list is just convenient for snippets really. Check out http://haskell.org/. It is a wiki, I think. One can search a lot of code there. Perhaps there should be something for ChucK. Hans