Section 5

How to Design Programs: An Introduction to Programming and Computing

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
How to Design Programs: An Introduction to Computing and Programming [Go to first , previous , next page; contents ; index ] Section 5 Symbolic Information [../icons/plt.gif] Symbols, Images These days computers mostly process symbolic information such as names, words, directions, or images. All modern programming languages support at least one way of representing symbolic information. Scheme supports several ways to express symbolic information: symbols, strings, (keyboard) characters, and images. A symbol is a sequence of keyboard characters 16 preceded by a single forward quotation mark: 'the 'dog 'ate 'a 'chocolate 'cat! 'two^3 'and%so%on? Like a number, a symbol has no inherent meaning. It is up to the function's user to relate symbolic data and real-world information, though the connection is typically obvious in a specific context. For example, 'east will usually refer to the direction where the sun rises, 'professor will be the title of a person teaching and researching at a university. [planets in DrScheme] Figure 7: The planets as images in DrScheme Like numbers, symbols are atomic pieces of data. Their purpose is to represent things such as family and first names, job titles, commands, announcements, and so on. Scheme provides only one basic operation on symbols: symbol=? , a comparison operation. It consumes two symbols and produces true if and only if the two symbols are identical: file:///C|/Documents%20and%20Settings/Linda%20Grauer. ..2/How%20to%20Design%20Programs/curriculum-Z-H-8.html (1 of 5) [2/5/2008 4:43:34 PM]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
How to Design Programs: An Introduction to Computing and Programming 1. (symbol=? 'Hello 'Hello) = true 2. (symbol=? 'Hello 'Howdy) = false 3. (symbol=? 'Hello x) = true if x stands for 'Hello 4. (symbol=? 'Hello x) = false if x stands for 'Howdy Symbols were first introduced to computing by researchers in artificial intelligence who wanted to design functions that could have conversations with people. Consider the function reply , which replies with some remark to the following greetings: ``good morning,'' ``how are you,'' ``good afternoon,'' and ``good evening.'' Each of those short sentences can be represented as a symbol: 'GoodMorning , 'HowAreYou , 'GoodAfternoon , and 'GoodEvening . Thus, reply consumes a symbol and replies with a symbol: ;; reply : symbol -> symbol ;; to determine a reply for the greeting s (define (reply s) . ..) Furthermore, the function must distinguish among four situations, implying, according to our design
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 5

Section 5 - How to Design Programs An Introduction to...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online