Fundamentals of CS I (CS151 2001S)
[Current]
[Discussions]
[Glance]
[Honesty]
[Instructions]
[Links]
[News]
[Search]
[Syllabus]
Primary
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Quizzes]
[Readings]
[Reference]
Sets
[Blackboard]
[Scheme Report]
[SamR's Schedule]
[Rebelsky/Fall 2000]
[Walker/Fall2000]
[Stone/Spring2000]
Links
If you have not done so already, you may want to skim the reading on chacters and strings.
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 list->string.
Here are two opposing views about the relationship between
string-length and string-ref:
str is, provided that it's not the
empty 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 procedure, (heading level text)
that generates a string that contains HTML heading of the appropriate
level. For example,
> (heading 2 "Exercise 6") "<h2>Exercise 6</h2>" > (heading 4 "History") "<h4>History</h4>"
You may find it useful to use the procedure
number->string.
a. Write a procedure, (markup tag text) that
surrounds text with the given tag. For example.
> (markup "p" "Hi There") "<p>Hi There</p>" > (markup "strong" "Wicked Neat!") "<strong>Wicked Neat!</strong>"
b. Use markup, string-append, and any other
procedures you deem appropriate to generate the following HTML:
<p> Sam says <q>Scheme is <strong>Wicked Neat!</strong></q> </p>
c. What are the advantages of using markup rather than marking
your code directly?
Note that you may want to use the character #\newline for
new lines.
Use markup to implement the following procedures, each of which takes one argument (some text) and generates HTML for appropriately formatted text.
a. bold
b. strong
c. paragraph
d. emphasize
a. Using the previous procedures, write a procedure, page,
of no arguments
that builds a simple HTML page of your choice. Your procedure will
begin
(define page
(lambda ()
instructions-for-building-the-page)))
You can call the procedure with (page).
b. Why might you use Scheme rather than a text editor to build a Web page?
Tuesday, 3 October 2000 [Samuel A. Rebelsky]
Wednesday, 7 February 2001 [Samuel A. Rebelsky]
Sunday, 18 February 2001 [Samuel A. Rebelsky]
markup based
on experience using it.
[Current]
[Discussions]
[Glance]
[Honesty]
[Instructions]
[Links]
[News]
[Search]
[Syllabus]
Primary
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Quizzes]
[Readings]
[Reference]
Sets
[Blackboard]
[Scheme Report]
[SamR's Schedule]
[Rebelsky/Fall 2000]
[Walker/Fall2000]
[Stone/Spring2000]
Links
Disclaimer: I usually create these pages on the fly. This means that they are rarely proofread and may contain bad grammar and incorrect details. It also means that I may update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.
This page was generated by Siteweaver on Thu May 3 23:08:06 2001.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2001S/strings.html.
You may validate
this page's HTML.
The source was last modified Sun Feb 18 21:52:35 2001.