Strings

Exercise 1

Is the symbol hyperbola a string?

Exercise 2

Is the character #\A a string?

Exercise 3

Does the null string count as a string?

Exercise 4

Suggest two ways of constructing the string ??? -- one using a call to make-string, the other a call to string.

Exercise 5

Here are two opposing views about the relationship between string-length and string-ref:

Which, if either, of these views is correct? Why?

Exercise 6

Write a Scheme procedure tally-vowels that takes one argument, a string, and determines how many characters in that string are vowels. (For this purpose, you should count only the ten characters #\a, #\e, #\i, #\o, #\u, #\A, #\E, #\I, #\O, and #\U as vowels.)

Exercise 7

Write a Scheme procedure consonant-part that takes one argument, a string, and returns a string similar to its argument except that all of the vowels have been removed. (For instance, the value of (consonant-part "asparagus") should be "sprgs".)


This document is available on the World Wide Web as

http://www.cs.grinnell.edu/~gum/courses/151/labs/strings.xhtml

created March 5, 1997
last revised August 11, 2001

Henry Walker (walker@math.grin.edu) and John David Stone (stone@cs.grinnell.edu) and Ben Gum (gum@cs.grinnell.edu)