问题
I just started learning a little Scheme, and I'm using Dorai Sitaram's Teach Yourself Scheme in Fixnum Days. In said work it is stated:
Scheme numbers can be integers (eg, 42) ... or complex (2+3i).
Emphasis mine. Note the form.
Using the principles I had been taught so far I tried writing a few different programs that dealt with the different kinds of numbers. I ended up writing this extremely simple snippet to test complex numbers:
(begin
(display 3+4i)
(newline)
)
Testing this on codepad.org (which uses MzScheme) and Ideone.com (which uses guile) worked perfectly.
Now, when I tried it with Chicken Scheme (my local development environment), it compiles fine, but when run, crashes and gives me the error:
Error: unbound variable: 3+4i
Call history:
main.scm:2: 3+4i <--
Apperently there's an unbound variable error, but with my limited Scheme I don't even know what that means (yet.)
Has anyone else experienced this? I know Chicken Scheme is supposed to be pretty standards compliant, and so it seems wierd that it wouldn't support something simple like this. I Googled through their documentation, but I couldn't find anything specific (although I think there is an external complex number library available, so perhaps that's a hint.)
If anyone has any suggestions, they'd be greatly appreciated. Thanks in advance! :)
回答1:
I believe you need to install the numbers extension for dealing with complex numbers in Chicken Scheme. Do this:
> chicken-install numbers
And don't forget to load it:
(use numbers)
来源:https://stackoverflow.com/questions/13504853/does-chicken-scheme-support-complex-numbers-if-so-why-am-i-getting-this-error