[plt-scheme] vector-fill! seems working out the wrong result

From: aladdin (buaa_aladdin at 163.com)
Date: Tue Sep 4 02:04:35 EDT 2007

Hi, all.

I had a problem when using vector-fill! to fill a dimension of 2D array.
Here is my code. Please note the second section of the code. First it
generate a 2x2 array with nested make-vector. Then, it called
vector-fill! to fill the second row of the array with value 10. But it
turns out that the whole 2x2 array is filled with 10.

Running the code under mzscheme works out the same result. Is it a bug?
Or is there something wrong with my code? Could anybody help? Thanks.


Dingding at DHF-LAPTOP1:~/code$ cat fill.scm
(define v '#(#(1 3) #(2 4)))
(display v)(newline)
(vector-fill! (vector-ref v 1) 10)
(display v)(newline)

(set! v (make-vector 2 (make-vector 2 1)))
(display v)(newline)
(vector-fill! (vector-ref v 1) 10)
(display v)(newline)

Dingding at DHF-LAPTOP1:~/code$ guile -s fill.scm
#(#(1 3) #(2 4))
#(#(1 3) #(10 10))
#(#(1 1) #(1 1))
#(#(10 10) #(10 10))

Dingding at DHF-LAPTOP1:~/code$ mzscheme.exe -fvm fill.scm
#(#(1 3) #(2 4))
#(#(1 3) #(10 10))
#(#(1 1) #(1 1))
#(#(10 10) #(10 10))

--
Ding Haifeng



Posted on the users mailing list.