[racket] how can I change only one element in the vector?
is this code right way to do it?
#lang racket
(define v (build-vector 2 (λ (n)
(build-vector 2 (λ (n)
(vector "1" "2" "3"))))))
(vector-set! (vector-ref (vector-ref v 0) 0) 0 "2")
v
On 20 November 2010 17:31, 김태윤 <kty1104 at gmail.com> wrote:
> thank you !
> could you tell me how to make new vector that does not refer to a single
> vector?
>
>
> On 20 November 2010 17:09, Neil Van Dyke <neil at neilvandyke.org> wrote:
>
>> "make-vector" is creating a new vector populated with *references* to a
>> single #("1" "2" "3") vector, *not* *copies* of the #("1" "2" "3") vector.
>>
>> Since you've created one #("1" "2" "3") vector, changing it through one
>> reference changes all references to it.
>>
>> (Aside to PLT people: This might be an example of having the default
>> writer show sharing could actually be helpful to beginners.)
>>
>> --
>> http://www.neilvandyke.org/
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101120/cb923b2d/attachment.html>