
From:  Thomas Chust 
Subject:  Re: [Chickenusers] complex numbers 
Date:  Sun, 08 Aug 2004 01:14:15 +0200 
Useragent:  Mozilla Thunderbird 0.5 (X11/20040306) 
Daniel B. Faken wrote:
Hi, Does anyone have a package for adding complex numbers to Chicken? (I'm looking for something like 90% compliance with R5RS)
Hello,well, I just needed something like that myself and as I remembered your message, I decided to do it properly. I have attached the compressed Scheme source code which can be installed as an egg for chicken.
The extension stores complex numbers as (real . imag) pairs. All numerical functions defined in the R5RS standard are redefined. The source is pure Scheme, which makes it probably not extraordinarily fast, but I can live with it and it should compile on any architecture.
The number>string function produces the notation "123+45i" from a complex number. The string>number function uses the regexcase extension and understands the following formats for complex numbers: "123+45i", "123*e^[]i2" and "(123 . 45)". Two nonstandard functions have been added: truecomplex? is a predicate which checks for a number from the set C\R and conj returns the complex conjugate of a number.
Please report bugs, if you find some! cu, Thomas
complex.scm.bz2
Description: Binary data
[Prev in Thread]  Current Thread  [Next in Thread] 