Vector set!, void vector problem 
Author Message
 Vector set!, void vector problem

Im writing a program to play a variant of the Mancala game. This
sniplet of code looks like it shouldn't give me a void error, but it
does. Anyone have any ideas why?

It has something to do with my LET statement, but ive done this before
and it's worked. So, any ideas?

(define huang-move-left
  (lambda (vec bowl)
    (letrec ([helper
              (lambda (count vect bw)
                (let ((v1 vect))
                  (if (zero? count)
                      (huang-make-vector-board v1)
                    (if (zero? bw)
                        (+ bowl 17)
                      (helper (- count 1) (vector-set! vect bw (+ (vector-ref vect
bw) 1)) (- bw 1))))))])
            (helper (car (huang-movelst vec bowl)) (list->vector (cdr
(huang-movelst vec bowl))) (- bowl 1)))))

the error im getting is: Error in vector-ref: #<void> is not a vector.

So, it's going to the vector ref first. If i can fix the void error,
then i know my set! will work as well. . .

Thu, 07 Jul 2005 04:09:01 GMT  
 Vector set!, void vector problem


>     (letrec ([helper
>          (lambda (count vect bw)
>                  (helper (- count 1) (vector-set! vect

The value returned by vector-set! is unspecified. Your current
implementation returns #<void>.

Thu, 07 Jul 2005 05:19:35 GMT  
 Vector set!, void vector problem
I see you've already received an answer, but I'm going to gratuitously
lecture you on how you could have approached this to find the answer

> It has something to do with my LET statement

No, it doesn't.  What makes you think that?  Are you just guessing?  You
don't need to guess, you can apply unassailable logic, instead, which is a
lot more reliable.  Here goes:

1.  'vect' is being set to void at some point.  So, look at the places that
the value of 'vect' is set, to find out where it is being set to void.
2.  The value of 'vect' in your code is only set whenever 'helper' is
3.  Therefore, one of the calls to 'helper' must be at fault.  So, look at
the values specified for the 'vect' parameter in each of your two calls to
5.  In the top-level call to 'helper', the value specified for 'vect' is the
result of a call to list->vector, which is a vector, not void.  So this call
is not the problem.
6.  In the other call to 'helper', the value specified for 'vect' is the
result of a call to vector-set!  Since the only other possibility has been
eliminated, this value must be the problem.  vector-set! is returning void.

Problems like this can be isolated and pinpointed simply by applying logic
and the most basic rules of Scheme.  No guesswork is required, and it's
usually quicker than asking someone else for an answer.  (Besides, that way
you won't get smartass answers like this one.)


Thu, 07 Jul 2005 05:44:45 GMT  
 [ 3 post ] 

 Relevant Pages 

1. no vector = vector*vector in BLAS?

2. matrix as vector of vectors

3. Inserting a vector slice into another vector

4. Optimal SSE code for dot producting 4 vectors with another vector for the Athlon

5. BLT vector creation: creation time grows as number of vectors created grows

6. (simple-vector 20) vs (vector single-float 20)

7. Vectors and Vector Spaces in ST80

8. Bit Vectored Identity Sets

9. Why no applicative vector-set in R5RS?

10. Int 25h (Set Vector Adr) Crashes WHY??

11. Setting/Getting interrupt vectors in 32 bit

12. Set Int 21h Vector


Powered by phpBB® Forum Software