Fundamentals of Computer Science I (CSC-151.02 2000F)


Control Structures

If-expressions and cond-expressions are two examples of control structures in Scheme -- expressions that control the order in which their subexpressions are evaluated or the circumstances under which they are evaluated. Scheme provides two other control structures that do conditional evaluation: the and-expression and the or-expression.

In an and-expression, the expressions that follow the keyword and are evaluated in succession until one is found to have the value #f (in which case the rest of the expressions are skipped and the #f becomes the value of the entire and-expression) or all of the expressions have been evaluated (in which case the value of the last expression becomes the value of the and-expression). This gives the programmer a way to combine several tests into one that will succeed only if all of its parts succeed.

In an or-expression, the expressions that follow the keyword or are evaluated in succession until one is found to have a value other than#f (in which case the rest of the expressions are skipped and this value becomes the value of the entire or-expression) or all of the expressions have been evaluated (the value of the or-expression is #f). This gives the programmer a way to combine several tests into one that will succeed if any of its parts succeeds.

History

Wednesday, 6 September 2000


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.

This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2000F/Readings/andor.html

Source text last modified Wed Sep 13 10:50:38 2000.

This page generated on Mon Sep 18 10:35:29 2000 by Siteweaver. Validate this page's HTML.

Contact our webmaster at rebelsky@grinnell.edu