CSC 153 | Grinnell College | Spring, 2005 |
Computer Science Fundamentals | ||
Laboratory Exercise | ||
This laboratory exercise helps you gain some experience developing and using Boolean expressions.
(and #t #t) (and #f #t) (and #t #f) (and #f #f) (and #t #t #t #t) (and #t #t #f #t) (or #t #t) (or #f #t) (or #t #f) (or #f #f) (or #t #t #t #t) (or #f #t #f #f) (or #f #f #f #f) (not #t) (not #f)In each case, explain why Scheme produced the result given.
(and 'cat #t) (and #f 'cat) (and 'cat #f) (and #f #f) (and #t #t 'cat #t) (and #t #t #t 'cat) (and #t #t #t 'cat 'dog) (or #t 'cat) (or 'cat #t) (or #f 'cat) (or 'cat #f) (or 'cat 'dog) (or #f #f) (not 'cat)In each case, state why you think Scheme produces the result given. Generalize the results to indicate what values and, or, and not return when they are applied to non-Boolean values.
(define not-and (lambda (A B) (not (and A B))))Explain why this procedure evaluates the logical expression "Not (A And B))".
This may be done with the copy or cp command as follows:
cp ~walker/153/labs/smallest.ss .This command should be executed in an hpterm window. Within this command, the final dot . is an abbreviation for your current directory. Thus, in this expression, you are telling the machine to copy (cp) the current file ~walker/153/labs/smallest.ss to your current directory. The new file will appear in your directory with the same name, smallest.ss. If you wanted the program to have a different name (e.g., my-program.ss), then you could change your copy command to:
cp ~walker/153/labs/smallest.ss my-program.ss
(if (???1) "A is smaller than both B or C." #then clause (;;; the else clause -- A is not smaller if (???2) #second condition within cond "B is smaller than both A and C." ;;; the second else cause -- B is not smaller either ??? etc. ) )
Note: Challenge Problems 1 and 2 are not required, but you may do either (or both) for extra credit.
This document is available on the World Wide Web as
http://www.walker.cs.grinnell.edu/courses/153.sp05/labs/lab-cond-if.shtml
created February 2, 1997 last revised January 26, 2005 |
![]() ![]() |
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |