[CM] cons value for float vector

James Hearon j_hearon at hotmail.com
Thu Sep 7 10:47:11 PDT 2023


Hi,
I'm having a difficult time trying to create two columns of data (or three or four etc.) in a float vector.
A list works fine, but the vector gives an error that the data is a pair but should
be a real.  I could use make-env for this probably, but seems like I should
be able to get the vector to cooperate.  I'm wondering what I'm misunderstanding or if there's
a better way to think of this such as individual vectors then zip them together?
Thanks,
Jim

;float vector XXX
(let* ((fsize 10)
       (im (make-float-vector fsize))
       (x 1)
       (y 1.0)
       )
(do ((k 0 (+ k 1)))
((>= k fsize))
(set! (im k) (cons x y)) ;XXX is a pair but should be a real?
;(float-vector-set! im k (cons x y))
(format #t "~% ~A ~A" k (im k) )
(set! x (1+ x))
(set! y (1+ y))
))

;list OK
(let* ((fsize 10)
       (mylist (make-list fsize))
       (x 1)
       (y 1.0)
       )
(do ((k 0 (+ k 1)))
((>= k fsize))
(set! (list-ref mylist k) (cons x y))
(format #t "~% ~A ~A" k (list-ref mylist k))
(set! x (1+ x))
(set! y (1+ y))
))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20230907/2168650d/attachment.html>


More information about the Cmdist mailing list