CSC153 2004S, Class 12: Strings Admin: * Questions on homework 3? * Homeworks 1 and 2 to be graded tonight * Talks today at 2:15 and 4:30 (Extra Credit) * Exam 1 assigned * Read "Pairs and Pair Structures" Question on Homework 3 * What kind of precondition checking should we do? * For example, in win (or whatever it's called), verify that both parameter lists contain only symbols, and that those symbols are legal scoring values. * Can we use our typechecking procedure? * Sure Questions on Exam * How does it differ from a homework? * You may not talk to others about it * You must turn in a printed copy * It's probably harder * Guaranteed minimum grade for particular time spent * How is it similar? * You do it on your own time * You can use reference materials * You can ask questions in class Overview: * Quick introduction * Lab Observation: * There are many ways to interpret *cat* * The name of something (e.g., a value, a procedure) (define cat ...) * A symbolic value 'cat * The sequence of letters c, a, t "cat" * Sequences of letters are called "strings" and are surrounded by double quote marks (as in "strings" earlier on this line) * The elements of those sequences are called characters: #\a #\A * Why are strings useful? * Versatile: Can permit different "types" of information (which must then be parsed) * Manipulable: Concatentate two strings; Eliminate part of it * Manipulate collections of strings: Sort * "Natural" way to represent lots of information * Programs may need to reflect "actual words" * How do lists and strings relate? * Both are ordered collections of values * lists can contain any kind of values * Strings contain only characters * Some applications naturally call for a string * Easier syntax for strings (#\c #\a #\t) vs. "cat" * Scheme provides operations for converting between the two (string->list "cat") => (#\c #\a #\t) (list->string (list #\c #\a #\t)) => "cat" * Scheme provides lots and lots of operations for dealing with characters and strings. * Learn through practice. * Try the lab, ask good questions