# Class 07: Pause for breath

Back to Basic types. On to Procedure definitions.

Held Tuesday, September 5, 2000

Summary

Today we pause for breath and consider how to solve some supposedly simple problems in Scheme.

Notes

• Handouts:
• Lab:
• I was sorry to see so few of you at yesterday's brown-bag lunch. It was actually quite interesting; there were videos of old GUI applications that seem more advanced than most things available today.
• Quiz: a. Take out a piece of paper b. Write your name at the top c. On the paper, write Scheme code for extracting the A from `(do (you (deserve an) (A)))` d. Raise your hand when you're done

Overview

• Quiz
• Some morals
• About `and` and `or`

## Quiz Discussion

• The problem: Extract the `A` from `(do (you (deserve an) (A)))`

### First Solution

• For our first solution, we used only `car` and `cdr`.

### Second Solution

• For our second solution, we used only `list-ref` and `reverse`.

### Morals

• Some problems are stupid/silly.
• Surprisingly enough, some of these silly problems really do occur in practice.
• Getting the details right is hard.
• Everybody has trouble with this stuff.
• Solve the problem a step at a time. Keep making small incremental updates that get you in the right direction.
• Work with other people.

## Combining Booleans

• At times, we want to combine boolean expressions. For example, ``Between X and Y, inclusive'' may be more precisely represented as ``At least as large as X and no larger than Y''.
• Similarly, ``Abnormal grade'' might be represented as ``smaller than 60 or larger than 100''.
• In Scheme, you can combine boolean expression with the `and` and `or` operators, which work similarly to the way they work in English.
• The `and` of two expressions is true if both expressions are true.
• The `and` of two expressions is false if either expression is false.
• The `or` of two expressions is true if either expression is true.
• The `or` of two expressions is false if both expressions are false.

## History

Thursday, 24 August 2000

• Created as a blank outline.

Tuesday, 5 September 2000

• Filled in the details.

Wednesday, 6 September 2000

• Rewrote the body when I found that it was best to spend class on the quiz.

Back to Basic types. On to Procedure definitions.

Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.