1. HW3
Homework: 12. Neither Algol 60 nore Algol 68
employs short-circuit evaluation for Boolean expressions. In both
languages, however, an if...then...else construct can be used
as an expression. Show how to use if...then...else to achieve
the effect of short-circuit evaluations.
I believe the right answer should be (just as the one we discussed at
class; talk to me if you still do not understand):
(1) A and then B
if A then B else false
(2) A or else B
if A then true else B
3. Lab1 will be in Scheme which has not been assigned yet. Will use
MzScheme to grade your lab.
4. DrScheme is a
programming env. for Scheme; you may find it very helpful. You can
download it from here.
6. Run your own program with MzScheme
Step 1: Save your code as *.scm file. You can do this with any text editor or the programming env. DrScheme.
Step 2: Copy your file *.scm to the directory where you would like to run MzScheme
Step 3: On the prompt, after you type mzscheme, type (load "*.scm")
Play with the fac example:
test 1: type fac on your prompt, you should see the following line
reference to undefined identifier: fac
Now, Save the folllowing fac function as fac.scm and put/upload it to your working directory.
(define fac
(lambda (x) (if (= x 0) 1 (* x (fac (- x 1))))))
test 2: type (load "fac.scm"), then type fac, you should see
#<procedure:fac>
and (fac 4) should give you 24
7. Let and its variants (next recitation)