Symbols and Strings

Symbols and Strings - another(among other things The only...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Symbols and Strings Symbols versus Strings Scheme provides two types of data for textual information. Symbols consist of a quote mark followed by a sequence of characters (including numbers and many punctuation marks) with no spaces: 'Kathi 'CS1101 and 'hot-dog are examples of symbols. Strings consist of a sequence of characters (including numbers, spaces, returns, and many punctuation marks) enclosed in double quotes: "Kathi" , "CS 1101" and "hot dog" are examples of strings. String and Symbol Operations 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
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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). Which Should I Use? 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). 1101 Home Page file:///C|/Documents%20and%20Settings/Linda%20Grauer/My. [2/5/2008 5:08:00 PM]...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online