Characters

Exercise 1

Determine the ASCII collating-sequence numbers for the capital letter A and for the lower-case letter a.

Exercise 2

Find out what ASCII character is in position 38 in the collating sequence.

Exercise 3

Do the digit characters precede or follow the capital letters in the ASCII collating sequence?

Exercise 4

If you were designing a character set, where in the collating sequence would you place the space character? Why? What position does it occupy in ASCII?

Exercise 5

In ASCII, the collating-sequence numbers of the control characters are 0 through 31 and 127. Define a predicate char-control? that returns #t if its argument is a control character, #f otherwise.

Exercise 6

Define and test a procedure named list-upcase that takes a list of characters as its argument and returns a similar list of characters, but with all of the lower-case letters converted to upper case.

> (list-upcase (list #\c #\a #\t))
(#\C #\A #\T)
> (list-upcase (list #\" #\W #\h #\a #\t #\? #\"))
(#\" #\W #\H #\A #\T #\? #\")
> (list-upcase null)
()

Exercise 7

Define and test a procedure named remove-whitespace that takes a list of characters as its argument and returns a similar list of characters, excluding all whitespace characters.

> (remove-whitespace (list #\a #\space #\l #\i #\s #\t
#\newline))
(#\a #\l #\i #\s #\t)

This document is available on the World Wide Web as

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

created October 8, 1997
last revised August 11, 2001

John David Stone (stone@cs.grinnell.edu) and Ben Gum (gum@cs.grinnell.edu)