mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-21 14:49:17 +02:00
Issue #55 - Create a complex num object
This commit is contained in:
parent
9dddfb882f
commit
8714206b9f
1 changed files with 5 additions and 11 deletions
|
@ -128,6 +128,10 @@
|
|||
"(void *data, int argc, closure _, object k, object opq)"
|
||||
" Cyc_string2number_(data, k, opaque_ptr(opq));")
|
||||
|
||||
(define-c Cyc-make-rect
|
||||
"(void *data, int argc, closure _, object k, object r, object i)"
|
||||
" Cyc_make_rectangular(data, k, r, i); ")
|
||||
|
||||
(define (parse fp)
|
||||
(let ((token (read-token fp)))
|
||||
;(write `(token ,token))
|
||||
|
@ -185,17 +189,7 @@
|
|||
(real (string->number real-str))
|
||||
(imag (string->number imag-str))
|
||||
)
|
||||
#;(if (= (+ 1 end) len)
|
||||
(let ((real "0")
|
||||
(imag (substring t 0 end))) ;; Only an imag part
|
||||
(write `(DEBUG ,t ,end ,len real ,(string->number real) imag ,(string->number imag))))
|
||||
(let ((real (substring t 0 end))
|
||||
(imag (substring t end (- len 1))))
|
||||
(if (= 0 (string-length imag))
|
||||
(set! imag "1"))
|
||||
(write `(DEBUG ,t ,end ,len real ,(string->number real) imag ,(string->number imag)))))
|
||||
;; TODO: actually do (make-rectangular real imag) or equivalent, instead of this debug result:
|
||||
(list t only-imag? end real imag)))
|
||||
(Cyc-make-rect real imag)))
|
||||
(else
|
||||
(error "Unexpected token" t)))))
|
||||
((= (vector-length token) 1) ;; Special case: error
|
||||
|
|
Loading…
Add table
Reference in a new issue