CSC 151 - Conditional evaluation in Scheme
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
- CSC 151 - Code Formatting and Styleeikmeier.sites.grinnell.edu
- CSC 151 - Anonymous procedureseikmeier.sites.grinnell.edu
- CSC 151 - Coding Challenge 1eikmeier.sites.grinnell.edu
- CSC 151 - Pattern matchingeikmeier.sites.grinnell.edu
- CSC 151 - Naming values with local bindingseikmeier.sites.grinnell.edu
- CSC 151 - List basicseikmeier.sites.grinnell.edu
- CSC 151 - Analyzing procedureseikmeier.sites.grinnell.edu
- CSC 151 - Coding Challenge 8eikmeier.sites.grinnell.edu
- CSC 151 - Mental models of computationeikmeier.sites.grinnell.edu
- Structure and Interpretation of Computer Programsmitp-content-server.mit.edu
- CSC 151 - Computation via Expressionseikmeier.sites.grinnell.edu
- Control Flow - The Rust Programming Languagedoc.rust-lang.org