CSC151.01 2009F Functional Problem Solving : Reference

Conditionals


(if test consequent alternative)
Standard keyword. Evaluate test. If its value is truish (that is, anything but false), evaluate consequent and return its value. If the value of test is false (#f), evaluate and return alternative.
(when test exp1 exp2 ... expn)
Optional Scheme Keyword. Evaluate test. If it holds, evaluate each expression in turn. Otherwise, do nothing.
(cond (test1 consequents1) (test2 consequents2) ... (testn consequentsn) (else alternative))
Standard keyword. Evaluate each test in turn until one is truish. It then evaluates the corresponding sequence of consequent expressions and returns the value of the last consequent. If none of the tests is truish, evaluates the alternative and returns its value.
(and exp1 exp2 ... expn)
Standard keyword. Evaluate each expression in turn. If any of those values is false, return false. Otherwise, return the value of the last expression.
(or exp1 exp2 ... expn)
Standard keyword. Evaluate each expression in turn. If any of those values is true, return true. Otherwise, return the value of the last expression.

Creative Commons License

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-9 Janet Davis, Matthew Kluber, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials copyright by John David Stone and Henry Walker and used by permission.)

This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.