|
CSE305 Spring 2008 - Navigation Menus
|
Homework 4
Assigned: Wednesday April 9, 2008.
Due: on or before 11:59 PM on Monday April 28, 2008.
This is your last homework of the semester!
When doing this homework, first create a directory named HW4
somewhere in your home directory (e.g. as a subdirectory of a
cse305 directory). Place your solution to each question in a
file or set of files, as indicated, in the HW4 directory.
When you're ready to submit, zip up the HW4 directory and its
contents, and use the submit_cse305 command to submit your
HW4.zip file. You can do this easily as follows. First,
make sure your current directory is the directory that contains
the HW4 directory. Next, issue the following command:
zip -r HW4 HW4
This will produce a file named HW4.zip which contains not
only the HW4 directory, but also its contents.
It is very important that you pay close attention to the naming
conventions for files and directories for you homework submissions in
this course. Having uniform names for all student submissions makes
grading submissions much easier. If you do not adhere to the naming
conventions, grading of your work will be delayed, or it may simply be
returned to you ungraded for you to correct the names.
For information on how to run the various programming language
compilers/interpreters, click here. You
will find resources for these languages on the course web site, under
the "Resources" page. You might the following page, listing available
CSE systems, helpful too: http://www-local.cse.buffalo.edu/Services/Data/Student/
POINTS: (100 points total)
Languages are C#, ML, and Prolog. Each language is worth 50 points.
You need only do two languages to get full credit. If you do all
three, you can get up to 150 points (which will "spill over" to help
other homework grades).
Requirements
In this homework you will add a bit more to our pseudo-Scheme
interpreter from homework 3. For this homework you may extend the
code you wrote for HW3, or you may use HW3 solutions which we will
provide on April 14 (when nobody can hand in HW3 for credit any more,
taking into account late days).
Your interactive Scheme-like interpreter must be extended to allow the
following expressions:
- true has value Boolean(true).
- false has value Boolean(false).
- (+ <expression>1
<expression>2)
is evaluated by evaluating both <expression>1
and <expression>2, and returning the
sum.
- (- <expression>1 <expression>2)
is evaluated by evaluating both <expression>1
and <expression>2, and returning the
difference.
- (* <expression>1 <expression>2)
is evaluated by evaluating both <expression>1
and <expression>2, and returning the
product.
- (/ <expression>1 <expression>2)
is evaluated by evaluating both <expression>1
and <expression>2, and returning the
quotient.
- (< <expression>1 <expression>2)
is evaluated by evaluating both <expression>1
and <expression>2, and returning Boolean(true)
if <expression>1 <
<expression>2, Boolean(false) otherwise.
- (= <expression>1 <expression>2)
is evaluated by evaluating both <expression>1
and <expression>2, and returning Boolean(true)
if <expression>1 =
<expression>2, Boolean(false) otherwise.
- (if <expression>1 <expression>2<expression>3)
is evaluated by first evaluating
<expression>1; if its value is
true, then the value of the if expression is the
value of <expression>2, else it is the
value of <expression>3.
- (lambda (<parameters>) <expression>)
is evaluated to form a closure.
- (<expression>1
<expression>2
... <expression>N) is evaluated by
first evaluating each expressoin, then applying the first
(which must be a closure) to the rest.
This page written an maintained by Carl Alphonce.
|