CSE 130: Principles of Programming Languages
Homework Assignments
BinProlog 4.00 binary for ACS Solaris machines is on the ACS directory for
CSE 130, /home/solaris/ieng9/cs130w/public/prolog/bp where everyone in
the class should have an account. The prolog/ directory mentioned
above also has a file ex1.pl that you may find useful. Some basic
notes on using BinProlog 4.00 are at
binpro.html. BinProlog 4.00 binary for CSE Solaris machines (such
as beowulf, bintijua, kongo, and machines in the APE lab) can be accessed via
/net/cs/class/wi99/cse230/prolog/bp, and also as a backup,
/net/cat/disk1/prolog/bp.
Solutions are now available for homework Set 2, Set 3, Set 4, Set 5, Set 6, and Set 7.
NOTES:
- Please hand in homework in paper hardcopy form; do not email me or the TA
an attachment! Computer printed paper is much preferred; if your handwriting
is too hard to read, you will lose points. You may also lose points if your
solution is too difficult to understand, whether due to English or technical
problems.
- Please give the assignment set number and problem number for each
question; also be sure to include your name, and the due date. If there are
multiple pages, you should staple them; since there are 160 students, loose
pages are likely to be lost, and you will not get credit.
- For problems that require use of a computer, always hand in both your
input and your output as part of your solution.
- Please do not ask the TAs, grader, or professor for help doing your
homework; this is not fair to other students. Especially, please do not do so
in a sneaky way; we have all been deluged with such questions by email, and
from now on we will take off points if you ask them. Of course, it is
acceptable to ask questions about the content of the course - indeed, it is
encouraged! And you can also ask about bugs in the homework questions (if
there are any).
- Assignments will normally be posted by Sunday, due on Thursday of the
following week. Homework due more than 5 days away is subject to change.
- Every problem you hand in will be checked, but only a random subset
(chosen to be maximally helpful to you, subject to our resource limitations)
will be graded; you will get up to 3 points for a problem that is handed in
and checked, and up to 10 points for one that is graded; of course, the total
for homework will be weighted appropriately when combined with the midterm and
final.
- Be sure to reload pages frequently, because sometimes they may be updated
frequently (i hope this is unnecessary since I have put meta tags on pages,
but it is not guaranteed).
- Prior to the midterm, homework problems were due Tueday, but now are due
Thursday. The problems should be on the website four days or more before they
are due.
- Due 15 January:
- Say where Java would go in the Figure on p.23 of Stansifer; write a
short paragraph of about 30 words justifying your choice. (You can just
photocopy the figure and add a line and dot for Java in red ink.)
- Briefly compare Java with at least three other languages from among those
described in Chapter 1 of Stansifer (FORTRAN, COBOL, BASIC, Algol, C, Lisp,
ML, Ada, C++, etc.); the languages that you choose for comparison should be
very different from each other.
Note: If you are unfamiliar with Java, you should be able to learn
enough to answer the above questions in about 30 minutes, by going to the
campus bookstore (or nearly any other bookstore in the country) and skimming
parts of one or more of the many Java books there.
- Due 22 January:
- Write a regular expression that will cause grep to search for, and print
the instances of, all the Ada identifiers (as defined on p.45 of Stansifer)
that occur as lines in an input file; test it on the file grep.data.html. You may use any convenient variant of
grep, such as egrep; you can type "man grep" or "man egrep" etc. at any Sun
workstation to learn what you need to know. Be sure to hand in your output
file, plus of course your regular expression.
- Exercise 2.3 of Stansifer (p.69).
- Exercises 2.8 and 2.9 of Stansifer (p.70).
- Due 29 January:
- Exercise 2.11 of Stansifer (p.71).
- Exercise 2.20 of Stansifer (p.73).
- Exercise 3.1 of Stansifer (p.100).
- Exercise 3.2 of Stansifer (p.100).
Note: The last two problems were added later than five days before the
due date, so they should be considered extra credit questions.
- Due 5 February: No homework is due this week; please study for the
midterm. The following questions, as well as some of those assigned for next
week, may help you with this.
- Exercise 3.5 of Stansifer (p.101).
- Exercise 3.8 of Stansifer (p.102).
- Exercise 4.3 of Stansifer (p.137).
- Due 12 February:
- Exercise 3.4 of Stansifer (p.101).
- Exercise 4.8 of Stansifer (p.138).
- Exercise 4.11 of Stansifer (p.138).
- Exercise 5.1 of Stansifer (p.179).
Note: Since material for problems 2.-4. was not covered in class
before the due date, it is ok to hand in answers to those problems as late as
19 February.
- Due 21 February:
- Exercise 5.3 of Stansifer (p.179).
- Exercise 5.4 of Stansifer (p.179).
- Exercise 5.5 of Stansifer (p.179).
- Due 5 March (was 28 February): Use Prolog for each problem; be sure to
include your input and your output; if you prefer to use another Prolog system
then BinProlog, you may do so, but you may have to use a somewhat different
syntax from that of BinProlog.
- Exercise 6.1 of Stansifer (p.208).
- Exercise 6.2 of Stansifer (p.209).
- Exercise 6.6 of Stansifer (p.210).
- Due 12 March (was 7 March): Use Prolog for each problem; be sure to
include your input and your output.
- Given the following relations
father(X,Y)
mother(X,Y)
female(X)
male(X)
for "X is the father of Y", "X is the mother of Y", "X is female", and "X is
male", define relations for the following:
- sibling (i.e., brother or sister);
- sister;
- grandson;
- first cousin; and
- descendent.
Test your code on some examples that are complex enough to show that it
works well.
- Using only the
append relation, formulate queries to
determine the following:
- the third element of a list;
- the last element of a list; and
- all but the last element in a list.
Test your code on some examples that are complex enough to show that it
works well.
- No homework is due 14 March; please review for the final exam.
To CSE 130 homepage
Maintained by Joseph Goguen
© 2000, 2001, 2002 Joseph Goguen
Last modified: Wed Apr 3 11:52:31 PST 2002