Conditional Expressions and Functions

For many problems, computer programs must deal with different situations in different ways. A game program may have to determine whether an object's speed is in some range or whether it is located in some specific area of the screen. For an engine control program, a condition may describe whether or when a valve is to be opened. To deal with conditions, we need to have a way of saying a condition is true or false; we need a new class of values, which, by convention, is called <#60540#><#1802#>BOOLEAN<#1802#><#60540#> (or truth) values. This section introduces Booleans, expressions that evaluate to Booleans, and expressions that compute values depending on the Boolean result of some evaluation. external ~<#60541#>Use the teachpack <#1804#>pingp-play.ss<#1804#> and have your students play the ping-pong game. To implement this kind of game, we need to conditional computing (is the ball at the boundary? is the ball on the paddle?) and compound data (the ball's position, the ball's velocity are data that have two components). Let's study these things in Scheme.<#60541#>