CS2322

Laboratory Problem 24

Working with Vectors

Define a procedure successive-powers that constructs a vector of length n whose entries are the successive powers of the number base. The element with index 0 is the 0th power of base. The procedure should be curried so that its first parameter is base, and the procedure that is returned has parameter n.

Tese your procedure on

((successive-powers 2) 8) ==> #(1 2 4 8 16 64 128)

((successive-powers 3) 5) ==> #(1 3 9 27 81)

Give a second definition of successive-powers which is based on the operator

vector-apply-elements-to-both.

Lab 24 Scheme Code