[Current] [News] [Glance] [Discussions] [Instructions] [Search] [Links] [Handouts] [Outlines] [Readings] [Labs] [Homeworks] [Quizzes] [Exams] [Examples] [Fall2000.01] [Spring2000]
If you have not done so already, you may want to skim the reading on chacters and strings. You do not need to read the appendix right now, but should do so eventuallly.
a. Determine the ASCII collating-sequence numbers for the capital letter A and for the lower-case letter a.
b. Find out what ASCII character is in position 38 in the collating sequence.
c. Do the digit characters precede or follow the capital letters in the ASCII collating sequence?
d. If you were designing a character set, where in the collating sequence would you place the space character? Why?
e. What position does the space character occupy in ASCII?
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.
a. Is the symbol hyperbola
a string?
b. Is the character #\A
a string?
c. Does the empty string count as a string?
Suggest three ways of constructing the string ???
-- one
using a call to make-string
, one a call to
string
, and one a call to string->list
.
a. 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) ()
b. Using list-upcase
, write a corresponding
string-upcase
that converts a string to all uppercase.
a. 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. (The newline,
the tab, and the space are the primary whitespace charactrers.)
b. Define a similar procedure that takes a string as an argument and returns the string with all the whitespace chaacters removed.
c. Define a similar procedure that can take a list or a string as an argument and returns the appropriate type of result (a list if given a list; a string if given a string).
Here are two opposing views about the relationship between
string-length
and string-ref
:
str
is, provided that it's not the
null string, (string-ref str (string-length str))
will return
the last character in the string.''
str
is, (string-ref str
(string-length str))
is an error.''
Which, if either, of these views is correct? Why?
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.)
Do not use string->list
in writing this procedure.
[Current] [News] [Glance] [Discussions] [Instructions] [Search] [Links] [Handouts] [Outlines] [Readings] [Labs] [Homeworks] [Quizzes] [Exams] [Examples] [Fall2000.01] [Spring2000]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2000F/Labs/strings.html
Source text last modified Tue Oct 3 11:07:28 2000.
This page generated on Tue Oct 3 11:10:35 2000 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu