any way to ask a vector it's length? I tried (length), but it seemed to complain that I wasn't dealing with a list. seems like a long road to turn it into a list first. I guess I should look up how to mess with vectors in scheme. I'm thinking you don't need to pass around the length in the interface.<br>
<br><div class="gmail_quote">On Mon, Feb 16, 2009 at 11:21 AM, Chongkai Zhu <span dir="ltr"><<a href="mailto:czhu@cs.utah.edu">czhu@cs.utah.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Yes, this is good (more than acceptable).<br>
<br>
Chongkai<br>
<br>
e wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
is something like this an acceptable approach? (just teat a linear array like a 2d array). seems like a better version of this stuff is probably part of the included stuff, I would imagine. Like there's probably a way to get the size of a vector. I was going to make a (array-2d-print) function, too that displays it like a grid ..... maybe tomorrow. Any suggested improvements or directions are of course welcome.<br>
<br>
(define (make-array-2d size initial)<br>
(make-vector (* size size) initial))<br>
<br>
(define (array-2d-ref array size row col)<br>
(vector-ref array (+ (* row size) col)))<br>
<br>
(define (array-2d-set! array size row col value)<br>
(vector-set! array (+ (* row size) col)))<br>
<br>
> (define deposits (make-array-2d 17 0))<br>
<br>
> (array-2d-ref deposits 17 0 11)<br>
0<br>
<br>
> (array-2d-set! deposits 17 0 11 39)<br>
<br>
> (array-2d-ref deposits 17 0 11)<br>
39<br>
<br>
<br>
<br></div></div><div class="Ih2E3d">
On Sat, Feb 14, 2009 at 4:40 PM, Chongkai Zhu <<a href="mailto:czhu@cs.utah.edu" target="_blank">czhu@cs.utah.edu</a> <mailto:<a href="mailto:czhu@cs.utah.edu" target="_blank">czhu@cs.utah.edu</a>>> wrote:<br>
<br>
and every slot of the vector is filled with `fill'. In your<br>
<br>
<br>
</div></blockquote>
<br>
</blockquote></div><br>