For a university project i have to make a game based in a matrix in the pretty big language, the matrix is being defined as a multidimensional vector. I need to set a single element of the matrix, my code is:
(require racket/vector)
(define test (make-vector 4 (make-vector 4 0)))
(define (matrix-set matrix row column value)
(vector-set! (vector-ref matrix row) column value)
)
(display test)(newline)
(matrix-set test 0 0 1)
(display test)
And outputs this:
#(#(0 0 0 0) #(0 0 0 0) #(0 0 0 0) #(0 0 0 0))
#(#(1 0 0 0) #(1 0 0 0) #(1 0 0 0) #(1 0 0 0))
I have searched the racket documentation and only found functions that set an element by making a new matrix, this and this questions too.
Why is the function setting the whole column instead of only the element?
What can be done to resolve it?