flâneur — a map of the web's best reading

CSC 151 - Conditional evaluation in Scheme

eikmeier.sites.grinnell.edu · 2,587 words · saved by 1 readers

When Scheme encounters a procedure call, it looks at all of the subexpressions within the parentheses and evaluates each one. Sometimes, however, the programmer wants Scheme to exercise more discretion. Specifically, the programmer wants to select just one subexpression for evaluation from two or more alternatives. In such cases, one uses a conditional expression, an expression that checks whether some condition is met and selects the subexpression to evaluate on the basis of the outcome of that condition. (We will sometimes refer to these conditions as “tests”. The tests (conditions) in conditionals are a question about the state of input or the system that let us make a decision.) For instance, suppose we want to explicitly classify a city as “North” if its latitude is at least 39.72 and “South” if its latitude is less than 39.72. To write a procedure that like this, we benefit from a mechanism that allows us to explicitly tell Scheme how to choose which expression to evaluate. Such

CSC 151 - Conditional evaluation in Scheme Conditional evaluation in Scheme Due Friday, 12 September 2025 --> Summary Many programs need to make choices. In this reading, we consider Scheme’s conditional expressions , expressions that allow programs to behave differently in different situations. Introduction When Scheme encounters a procedure call, it looks at all of the subexpressions within the parentheses and evaluates each one. Sometimes, however, the programmer wants Scheme to exercise more discretion. Specifically, the programmer wants to select just one subexpression for evaluation from

Explore this link on the map →

saved by

related reading