guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

vector-fill! seems giving out the wrong result


From: aladdin
Subject: vector-fill! seems giving out the wrong result
Date: Tue, 04 Sep 2007 13:50:19 +0800
User-agent: Thunderbird 2.0.0.6 (Windows/20070728)

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.


address@hidden:~/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)

address@hidden:~/code$ guile -s fill.scm
#(#(1 3) #(2 4))
#(#(1 3) #(10 10))
#(#(1 1) #(1 1))
#(#(10 10) #(10 10))

address@hidden:~/code$ mzscheme.exe -fvm fill.scm
#(#(1 3) #(2 4))
#(#(1 3) #(10 10))
#(#(1 1) #(1 1))
#(#(10 10) #(10 10))

--
Ding Haifeng
address@hidden

2007-09-04





reply via email to

[Prev in Thread] Current Thread [Next in Thread]