|CSC 153||Grinnell College||Spring, 2005|
|Computer Science Fundamentals|
This laboratory exercise provides practice with iteration through the use of Scheme's do-expression.
Write a procedure
display-count that takes two arguments,
finish, and counts upwards from
finish, displaying each number on a
separate line. (The preconditions are that
finish must both be exact integers and
be less than or equal to
display-count procedure should return the number of lines of
output it produces.
sqrt-table procedure from the lab on input and output. This
procedure takes one argument, a non-negative 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 sqrt-table used a helper function to handle the printing of each line, after the initial header was printed.
Rewrite the sqrt-table-helper function by using a
Define a Scheme procedure that takes any non-empty 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
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 do-expression for any looping. Finally, keep the number of variables in your do-expression to a minimum -- for example, the string variable should not be redefined in the loop.
Rewrite the encode-char procedure (including its kernel procedure) from the lab on strings, so that all looping is done using a do-expression.
This document is available on the World Wide Web as
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 firstname.lastname@example.org.|