title: Dot product of vectors
body: <p>I was wondering how to get the dot product of two vectors.</p>
  
  <pre><code>(check-expect (dot (vector 5 1 1) (vector 1 0 0)) (+ 5 0 0))
  (check-expect (dot (vector 1 1 5) (vector 1 0 0)) (+ 1 0 0))
  </code></pre>
  
  <p>So essentially I'm trying to build a function (dot) that will satisfy these two check expects.</p>
  
  <p>So far I have only started this by defining the function</p>
  
  <pre><code>(define (dot vec1 vec2)
  </code></pre>
  
  <p>I had previously defined a function (vfold) that is the same as foldl except that vfoldl works on vectors rather than lists, but am not sure if I have to use it for this new function.</p>
  
  <pre><code>; vfoldl: (X Y --&gt; Y) Y [VectorOf X] --&gt; Y
  (define (vfoldl combine base avec)
    (local [(define imax (sub1 (vector-length avec)))
            (define (vaux combine avec index acc)
              (cond [(= index imax) (combine (vector-ref avec imax) acc)]
                    [else (vaux combine
                                avec
                                (add1 index)
                                (combine (vector-ref avec index)
                                         acc))]))]
     (vaux combine avec 0 base)))
  </code></pre>