[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] complex numbers

From: Thomas Chust
Subject: Re: [Chicken-users] complex numbers
Date: Sun, 08 Aug 2004 01:14:15 +0200
User-agent: Mozilla Thunderbird 0.5 (X11/20040306)

Daniel B. Faken wrote:

  Does anyone have a package for adding complex numbers to Chicken?
  (I'm looking for something like 90% compliance with R5RS)


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 regex-case extension and understands the following formats for complex numbers: "123+45i", "123*e^[-]i2" and "(123 . 45)". Two nonstandard functions have been added: true-complex? 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!


Attachment: complex.scm.bz2
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]