Re: complex bug
Vadim Zborovskii <[email protected]>
| Newsgroups | gmane.lisp.scheme.scheme48 |
|---|---|
| Message-ID | <[email protected]> |
>
> When I try to make a complex with the procedure <make-polar> in
> scheme48 1.8, the interpreter always returns an error,
> said that "wrong-type-argument".
>
> So I checked r5rs fund that I did nothing wrong.
>
> I use scheme48 in winXP.
> with a picture of the problem.
Scheme48 doesn't have make-polar as yet. The following patch works for
me (for version 1.8).
diff -r 1f349e4f8f3b scheme/rts/xnum.scm
--- a/scheme/rts/xnum.scm Wed Mar 05 09:16:57 2008 +0100
+++ b/scheme/rts/xnum.scm Wed Jul 30 04:37:46 2008 +0400
@@ -133,6 +133,7 @@
(define-opcode-extension denominator &denominator)
(define-opcode-extension make-rectangular &make-rectangular)
+(define-opcode-extension make-polar &make-polar)
(define-opcode-extension exp &exp)
(define-opcode-extension log &log)
@@ -358,3 +359,8 @@
(if (char=? c (string-ref s i))
i
(loop (+ i 1))))))
+
+; make-polar
+(define-method &make-polar ((m :real) (theta :real))
+ (make-rectangular (* m (cos theta))
+ (* m (sin theta))))
The code was borrowed from http://paste.lisp.org/display/30061. I hope
it will get merged into tree someday :-)
As a workaround, execute the following in your scheme48 session:
,open extended-numbers methods
(define-opcode-extension make-polar &make-polar)
(define-method &make-polar ((m :real) (theta :real))
(make-rectangular (* m (cos theta))
(* m (sin theta))))
Now make-polar will work for this session.
Best regards,
Vadim Zborovskii