CSC151.02 2003F, Class 13: Characters and Strings Admin * No reading! * Instead: Shizzilator and Pirate translator Overview: * What types do you know so far? * Characters * Strings * Questions and Answers * Lab * Reflections Languages benefit from having different "types" of values that we think of (and use) in different ways. * Characters * Strings * Characters are the building blocks of strings. * Strings are combinations of characters. * A string normally represents something your program might print. (E.g., the text of a book, a Web page, etc.) * These "strings" are built from smaller things. * The smaller things are characters. * Strings are distinguished from symbols in that you expect to "take apart" and otherwise manipulate strings. * Represent strings by surrounding them with quotes. * "Samuel A. Rebelsky" * "We the people of the United States, in order to form a more perfect union, establish justice, ensure domestic tranquility, provide for the common defense, promote the general welfare, and secure the blessings of liberty to ourselves and our posterity do ordain and establish this consitution." * "'Twas brilling and the slithy toves did gyre and gimble in the wabe." * Represent character a with #\a * To distinguish it from the name a, the symbol 'a, the string "a" * You can join, segment, change, compare, etc. strings. Are there questions? Do the lab. ----- /Reflection/ (define control-char? (lambda (ch) (and (char? ch) (or (= (char->integer ch) 127) (<= 0 (char->integer ch) 31))))) (define heading (lambda (level text) (string-append "string level) ">" text "string level) ">")))