Start DrScheme and tell it not to print the lengths of vectors.
In DrScheme's interaction window, type in a vector literal that denotes a vector containing just the two elements 3.14159 and 2.71828. How does DrScheme display the value of this vector?
Develop a vector-sum procedure that takes one argument, a vector of
numbers, and returns the sum of the elements of that vector. (You can use
our-vector->list as a pattern for vector-sum -- only a few
judicious changes are needed.)
Develop a Scheme procedure join-strings that takes two
arguments, both vectors of strings, equal in length, and returns a third
vector of the same length, containing the results of concatenating
corresponding elements of the argument vectors.
> (join-strings (vector "sect" "ram" "wee") (vector "ion" "pant" "knights"))
#("section" "rampant" "weeknights")
Develop a Scheme procedure reverse-vector that takes any vector as
argument and returns a vector of the same length, containing the same
elements, but in reverse order.
The dot product of two equally long vectors of numbers is the
sum of the products of corresponding elements of those vectors. Develop
a Scheme procedure dot-product that computes the dot product of two
given vectors of numbers.
> (dot-product '#(2 3 4) '#(5 6 7)) 56 ; (2 x 5) + (3 x 6) + (4 x 7) = 56 > (dot-product '#(3 1 4 1 6) '#(2 7 1 8 3)) 43 > (dot-product '#() '#()) 0
(Thanks to Alison McQuillan 2004 for pointing out an error in a previous version of this exercise.)
I am indebted to Professor Ben Gum for his contributions to the development of this lab.