Thanks (again) Rodolfo,<div><br></div><div>Do people use the srfi/25 arrays much? Or is the normal practice to simply use vector with a little "reference arithmetic"?</div><div><br></div><div>-Joe<br><br><div class="gmail_quote">
On Mon, Mar 26, 2012 at 9:26 PM, Rodolfo Carvalho <span dir="ltr"><<a href="mailto:rhcarvalho@gmail.com">rhcarvalho@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote">Hi Joe,<div class="im"><br><br>On Mon, Mar 26, 2012 at 21:22, Joe Gilray <span dir="ltr"><<a href="mailto:jgilray@gmail.com" target="_blank">jgilray@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Pierpaolo,<div><br></div><div>Yes, I could read the data into a list and then create an array from it:</div><div><br></div><div><div>(array-ref (apply array (shape 0 3 0 3) '(1 2 3 4 5 6 7 8 9)) 2 2)</div><div>9</div>
<div><br></div><div>But, I don't seem to be able to do the same from a vector:</div><div><br></div><div><div>(array-ref (apply array (shape 0 3 0 3) #(1 2 3 4 5 6 7 8 9)) 2 1)</div><div>apply: expects type <proper list> as 3rd argument, given: '#<a href="tel:%281%202%203%204%205%206%207%208%209" value="+48123456789" target="_blank">(1 2 3 4 5 6 7 8 9</a>); other arguments were: #<procedure:array> #<array:srfi-9-record-type-descriptor></div>
<span><font color="#888888">
</font></span></div><span><font color="#888888"><div><br><br></div></font></span></div></blockquote></div><div><br><br>It's late night here and I didn't look at the docs, but from the error message it seems that you cannot pass a vector to the array constructor.<br>
With a vector at hand, we can use vector->list to do the appropriate conversion:<br><br>(array-ref (apply array (shape 0 3 0 3) (vector->list #(1 2 3 4 5 6 7 8 9))) 2 1)<br><br><br>On racket.exe:<br><br>Welcome to Racket v5.2.1.<br>
> (require srfi/25)<br>> (array-ref (apply array (shape 0 3 0 3) (vector->list #(1 2 3 4 5 6 7 8 9))) 2 1)<br>8<br><br><br><br></div></div>[]'s<span class="HOEnZb"><font color="#888888"><br><br>Rodolfo<br>
</font></span></blockquote></div><br></div>