previous | index | next

Exercise 13.9

As the exercise directs, rewrite push! to enlarge the stack when necessary by doubling the vector's size.

The test file will evaluate an expression that will cause the stack size to be doubled twice:

**************************************************************
Results for Exercise 13.9

Enlarging stack ...
Enlarging stack ...
Assertion OK:
(=
 (evaluate (1+(2+(3+(4+(5+(6+(7+(8+9)))))))))
 45)

Note that push! issues a message when the stack size doubles first from 8 to 16, and again from 16 to 32.

See suggestions on next slide.


previous | index | next