Scheme provides two types of data for textual information.
'Kathi
'CS1101
and 'hot-dog
are
examples of symbols."Kathi"
, "CS 1101"
and
"hot dog"
are examples of strings.
The best way to get the current list of string operations is to open DrScheme's HelpDesk (under the help menu) and search for string. You'll find contracts and purpose statements for all string operations defined at your current language level. The operations let you compare strings (for equality or alphabetical order), glue them together (also called concatenation), and search for one string inside another (among other things).
The only operation that specifically handles symbols is checking
whether two symbols are the same (using symbol=?
). You
cannot perform any operation that requires looking at the characters
in the symbol (as alphabetic ordering would require).
Symbols are good for enumerating a fixed set of choices that you
want to represent as words (like 'small
,
'medium
, 'large
). If you want data that can
have a non-standard number of variations, such as names, use strings.
You can use punctuation marks to get the effect of space in symbols
(as we did with the 'hot-dog
symbol).