Strings

Course links

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

Design, write, and test 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

Design, write, and test 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".)

Exercise 8

Design, write, and test a Scheme procedure that constructs and returns a ``letterspaced'' version of a given string by inserting an extra space after every non-whitespace character in the string except the last.

> (letterspace "wombat")
"w o m b a t"
> (letterspace "Spread out the text!")
"S p r e a d  o u t  t h e  t e x t !"
> (letterspace "oo")
"o o"
> (letterspace "I")
"I"
> (letterspace "")
""

Exercise 9

Standard Scheme does not provide procedures for converting all the letters in a string to upper case or to lower case. Remedy this defect by writing your own string-upcase and string-downcase procedures.

The principal author of this lab is Professor Henry Walker. I am also indebted to Professor Ben Gum for his contributions to its development.