CSC 153  Grinnell College  Spring, 2005 
Computer Science Fundamentals  
Laboratory Exercise  
This laboratory exercise provides practice with iteration through the use of Scheme's doexpression.
Write a procedure displaycount
that takes two arguments,
start
and finish
, and counts upwards from
start
to finish
, displaying each number on a
separate line. (The preconditions are that start
and
finish
must both be exact integers and start
must
be less than or equal to finish
.) The
displaycount
procedure should return the number of lines of
output it produces.
Review the sqrttable
procedure from the lab on input and output. This
procedure takes one argument, a nonnegative integer, and prints out a
table of integers and their square roots, for integers equal to or less
than its argument.
In printing the table of square roots, procedure sqrttable used a helper function to handle the printing of each line, after the initial header was printed.
Rewrite the sqrttablehelper function by using a
do
expression.
Define a Scheme procedure that takes any nonempty list of real numbers
as its argument and returns the number that is the greatest element of the
list. Use a do
expression to run through the positions of
the list.
Define a sum
procedure, which takes any list of numbers as its
argument and returns their sum. In your procedure, use a
do
expression to process list elements iteratively.
Write a procedure that counts the number of vowels that occur in a string. Within your procedure, keep the string in tact  do not convert it to a list. Also, use a doexpression for any looping. Finally, keep the number of variables in your doexpression to a minimum  for example, the string variable should not be redefined in the loop.
Rewrite the encodechar procedure (including its kernel procedure) from the lab on strings, so that all looping is done using a doexpression.
This document is available on the World Wide Web as
http://www.cs.grinnell.edu/~walker/courses/153.sp05/labs/labiteration.shtml
created April 21, 1997 by John David Stone last revised February 2, 2005 by Henry M. Walker 

For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. 