TO RUN these vector, matrix, let, let*, and do loop examples:

> (define v1 (makeNVector 10 50))
> v1
#10(49 33 39 20 28 30 10 38 16 25)
> (square-array v1)
#10(2401 1089 1521 400 784 900 100 1444 256 625)
> (avg-array v1)
28 4/5

> (mult-table 5 5)
#5(#5(1 2 3 4 5)
   #5(2 4 6 8 10)
   #5(3 6 9 12 15)
   #5(4 8 12 16 20)
   #5(5 10 15 20 25))

   
;; returns a vector of length n filled with 
;; random numbers from 0..m
(define (makeNVector n m)
  (let* ((v (make-vector n)))
    (do ((i 0 (+ i 1)))
      ((= i n) v)
      (vector-set! v i (random m)))))

;; creates a matrix - a vector of vectors, each row of the matrix is a vector
(define (make-matrix rows columns)
  (do ((m (make-vector rows))
       (i 0 (+ i 1)))
    ((= i rows) m)
    (vector-set! m i (make-vector columns))))

;; creates a matrix - a vector of vectors, each row of the matrix is a vector
;; with random values up to rannumber
(define (makeNmatrix rows columns rannumber)
  (do ((m (make-vector rows))
       (i 0 (+ i 1)))
    ((= i rows) m)
    (vector-set! m i (makeNVector columns rannumber))))

(define (square-array v1)
  (let* ((len (vector-length v1))
         (v2 (make-vector len)))
    (do ((i 0 (+ i 1)))   ;; start the counter i at 0, increment by 1
      ((= i len) v2)   ;; stop when i = len, return the new vector v2
      (vector-set! v2 i (sqr (vector-ref v1 i))))))

(define (avg-array v1)
  (let ((sum 0)
        (len (vector-length v1))
        (avg 0))
    (do ((i 0 (+ i 1)))   ;; start the counter i at 0, increment by 1
      ((= i len) (set! avg (/ sum len)) avg) ;; stop when i = len, return avg
      (set! sum (+ sum (vector-ref v1 i)))))) 

(define (mult-table rows cols)
  (let ((m (make-matrix rows cols)))
    (do ((row 0 (+ row 1)))
      ((= row rows) m)
      (do ((col 0 (+ col 1)))
        ((= col cols))
        (matrix-set! m row col (* (+ row 1) (+ col 1)))))))


(define (make-matrix rows columns)
  (do ((m (make-vector rows))
       (i 0 (+ i 1)))
    ((= i rows) m)
    (vector-set! m i (make-vector columns))))


(define (matrix-ref m i j)
  (vector-ref (vector-ref m i) j))

(define (matrix-set! m i j x)
  (vector-set! (vector-ref m i) j x))