Member Avatar for BobTheLob

Hey, so I'm working on the game set-cubed in Scheme (for those who know the game). Currently, i have a csv file of all the possible dice with dice faces. I'm trying to read this into scheme, and managed to do that with a csvreadermaker. Currently, i can get it into a vector, but i want to pull out individual items in this vector to compare. Preferably, i want something that I can use that acts similarly to a 2 dimensional array. Here's what I have:

(require (planet neil/csv:1:6/csv))


(define set-cubed-csv-reader ;#####Creating our reader for the CSV file#####
  (make-csv-reader-maker
   '((separator-chars #\,)
     (strip-leading-whitespace? . #t)
     (srtip-trailing-whitespace? . #t))))

 (define next-row
    (set-cubed-csv-reader (open-input-file "setcubed.csv"))) ;####We just defined (next-row) to give us the next row in each line of setcubed.csv

This is some output:
> (define v (next-row))
> v
("dienum" "face1" "face2" "face3" "face4" "face5" "face6")

I want to be able to pull each element out of the vector, but also easily be able to get more vectors for the next line down in the csv file.
How do I go about doing this?

Member Avatar for BobTheLob

:P Ha ha, having a similar problem?
I actually managed to get it to work! Turns out that when I did that (above), i get a list instead. It's weird,going back and forth between lists and vectors.

I'm actually trying to figure out how to read the csv in haha I was using an example in the powerpoint but that wasn't working very well for me so I was looking for a better way to read it...

but I thought it was pretty funny that I came across this haha

Thanks! yeah it's just under slides in the t drive but apparently they're just slowing me down! haha I hope I dont't have to stay up all night...

did you figure out how to index the list?

Member Avatar for BobTheLob

you mean pop it into a vector? I managed to put it inside a vector of a vector, and then went through and grabbed a "dice" and then a "face". My problem now is doing proper equality checks with strings

how did you go from list to vector?

oh nvm figured it out haha

Member Avatar for BobTheLob

list->vector

I don't understand this!! I can't index the vector. it's just stored as one big vector and when I call the 0th index it gives me the exact same vector, I can't access parts of it

oh wait... nvm I'm an idiot, ignore me haha

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.