[racket] do loops in racket, also srfi/25 query
Thanks (again) Rodolfo,
Do people use the srfi/25 arrays much? Or is the normal practice to simply
use vector with a little "reference arithmetic"?
-Joe
On Mon, Mar 26, 2012 at 9:26 PM, Rodolfo Carvalho <rhcarvalho at gmail.com>wrote:
> Hi Joe,
>
>
> On Mon, Mar 26, 2012 at 21:22, Joe Gilray <jgilray at gmail.com> wrote:
>
>> Hi Pierpaolo,
>>
>> Yes, I could read the data into a list and then create an array from it:
>>
>> (array-ref (apply array (shape 0 3 0 3) '(1 2 3 4 5 6 7 8 9)) 2 2)
>> 9
>>
>> But, I don't seem to be able to do the same from a vector:
>>
>> (array-ref (apply array (shape 0 3 0 3) #(1 2 3 4 5 6 7 8 9)) 2 1)
>> apply: expects type <proper list> as 3rd argument, given: '#(1 2 3 4 5 6
>> 7 8 9); other arguments were: #<procedure:array>
>> #<array:srfi-9-record-type-descriptor>
>>
>>
>>
>
> 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.
> With a vector at hand, we can use vector->list to do the appropriate
> conversion:
>
> (array-ref (apply array (shape 0 3 0 3) (vector->list #(1 2 3 4 5 6 7 8
> 9))) 2 1)
>
>
> On racket.exe:
>
> Welcome to Racket v5.2.1.
> > (require srfi/25)
> > (array-ref (apply array (shape 0 3 0 3) (vector->list #(1 2 3 4 5 6 7 8
> 9))) 2 1)
> 8
>
>
>
> []'s
>
> Rodolfo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120327/52122e78/attachment.html>