fasl reader/writer now understands complex numbers.
This commit is contained in:
parent
0a6df79e3b
commit
8827b98972
|
@ -364,6 +364,12 @@
|
|||
(let ([x (/ num den)])
|
||||
(when m (put-mark m x))
|
||||
x))]
|
||||
[(#\i) ;;; compnum
|
||||
(let* ([real (read)]
|
||||
[imag (read)])
|
||||
(let ([x (make-rectangular real imag)])
|
||||
(when m (put-mark m x))
|
||||
x))]
|
||||
[else
|
||||
(die who "Unexpected char as a fasl object header" h)])))
|
||||
(read))
|
||||
|
|
|
@ -281,6 +281,10 @@
|
|||
(write-byte ($bignum-byte-ref x i) p)
|
||||
(f (fxadd1 i)))))
|
||||
m]
|
||||
[(compnum? x)
|
||||
(put-tag #\i p)
|
||||
(fasl-write-object (imag-part x) p h
|
||||
(fasl-write-object (real-part x) p h m))]
|
||||
[else (die 'fasl-write "not fasl-writable" x)])))
|
||||
(define (write-bytevector x i j p)
|
||||
(unless ($fx= i j)
|
||||
|
@ -373,6 +377,9 @@
|
|||
[(ratnum? x)
|
||||
(make-graph (numerator x) h)
|
||||
(make-graph (denominator x) h)]
|
||||
[(compnum? x)
|
||||
(make-graph (real-part x) h)
|
||||
(make-graph (imag-part x) h)]
|
||||
[else (die 'fasl-write "not fasl-writable" x)])]))))
|
||||
(define fasl-write-to-port
|
||||
(lambda (x port)
|
||||
|
|
|
@ -1 +1 @@
|
|||
1484
|
||||
1485
|
||||
|
|
|
@ -25,8 +25,10 @@
|
|||
(test 3498798327498723894789237489324)
|
||||
(test -3498798327498723894789237489324)
|
||||
(test 2389478923749872389723894/23498739874892379482374)
|
||||
(test -2389478923749872389723894/23498739874892379482374)))
|
||||
|
||||
|
||||
(test -2389478923749872389723894/23498739874892379482374)
|
||||
(test 127487384734.4)
|
||||
(test (make-rectangular 12 13)))
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue