Next: About this document
Up: No Title
Previous: Sorting lists
Remember that for dealing with vectors you have the following constructors and selectors:
- (make-vector n) : function that returns a vector of length n.
- (vector-length v) : function that returns the length of vector v.
- (vector-ref v i) : function that returns the (i+1)-st element of vector v
(for example (vector-ref v 0) is the first element of the vector v).
- (a)
- [5 points] Write a function max-vector that computes the maximum value in a vector,
e.g. (max-vector #(2 -5 7 4))
7 (remember you are dealing with
vectors here, not with lists, i.e. things like map etc. won't work).
- (b)
- [5 points] Write a function vector->list that converts a vector into a list
containing the same elements, e.g. (vector->list #(2 5 4 3))
(2 5 4 3).
Behfar Bastani-Booshehri
Wed Dec 9 10:04:14 CST 1998