[plt-scheme] nested vectors

From: Noel Welsh (noelwelsh at gmail.com)
Date: Mon Feb 16 07:50:23 EST 2009

On Mon, Feb 16, 2009 at 5:04 AM, e <eviertel at gmail.com> wrote:
> is something like this an acceptable approach?
...
>
> (define (make-array-2d size initial)
>   (make-vector (* size size) initial))
>
> (define (array-2d-ref array size row col)
>   (vector-ref array (+ (* row size) col)))
>
> (define (array-2d-set! array size row col value)
>   (vector-set! array (+ (* row size) col)))

Yeah, that is a pretty standard solution.  If you aren't doing this
just as a learning exercise look at the matrix package on planet by
Will Farr.

N.


Posted on the users mailing list.