Re: [racket] do loops in racket, also srfi/25 query

2012-03-28 Thread Pierpaolo Bernardi
On Tue, Mar 27, 2012 at 18:55, Joe Gilray wrote: > 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"? The most normal practice, I think, is to use nested vectors, maybe with a few ad-hoc help f

Re: [racket] do loops in racket, also srfi/25 query

2012-03-27 Thread Joe Gilray
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 wrote: > Hi Joe, > > > On Mon, Mar 26, 2012 at 21:22, Joe Gilray wrote: > >> Hi Pierpaolo,

Re: [racket] do loops in racket, also srfi/25 query

2012-03-26 Thread Rodolfo Carvalho
Hi Joe, On Mon, Mar 26, 2012 at 21:22, Joe Gilray 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: > > (arr

Re: [racket] do loops in racket, also srfi/25 query

2012-03-26 Thread Joe Gilray
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: expect

Re: [racket] do loops in racket, also srfi/25 query

2012-03-26 Thread Pierpaolo Bernardi
On Mon, Mar 26, 2012 at 01:31, Joe Gilray wrote: > Hi Tom, > > thanks for the comments. > > As far as reading the data into a vector, that can be accomplished with > "(define vec (read in))"  I was more interested in how to create an srfi/25 > array from that vector. (apply array (shape 0 3 0 3)

Re: [racket] do loops in racket, also srfi/25 query

2012-03-25 Thread Joe Gilray
Hi Tom, thanks for the comments. As far as reading the data into a vector, that can be accomplished with "(define vec (read in))" I was more interested in how to create an srfi/25 array from that vector. Thanks also for the example of using for*/fold. -Joe On Sat, Mar 24, 2012 at 11:26 PM,

Re: [racket] do loops in racket, also srfi/25 query

2012-03-24 Thread Tom McNulty
The format of prob11's data is already quite close to what the reader expects for a vector, so you can read it directly by including #( ... (define tbl #(08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 ... 01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48)) A

[racket] do loops in racket, also srfi/25 query

2012-03-24 Thread Joe Gilray
I was playing around with ProjectEuler #11 and found a lisp solution and adapted it to Racket. Part of the solution had code like the following to find products of values in a 20x20 vector. (define (prod-of-vec-lines-of-length-4 v ix iy dx dy) (do ([p 1 (* p (if (in-vector? x y 20 20) (vector-r