CSE 3341, Scheme Lab
Grade: This assignment is worth 40 points.
Copyright By Assignmentchef assignmentchef
Note: We havent worked on Scheme enough for me to give you a really interesting project in it, so this
is really a fairly simple (and, by itself, pointless) assignment. All it does is make sure that you get some
practice in thinking functionally (which is a useful thing) and play with Scheme a little bit. If you want to get
into Scheme, and it is worth getting into, the book The Structure and Interpretation of Computer Programs
by Abelson and Sussman is highly recommended.
Problem: The assignment is to write a function, eliminateNsort, which will receive two lists of num-
bers as arguments. Suppose L1, L2 are the two lists. The result returned by the function should be obtained
from L1, L2 as follows: start with L1 and remove from it all those elements that are also in L2; then sort the
remaining elements into non-decreasing order to get the result list.
The terminology in the last paragraph is somewhat incorrect. You do not actually want to remove anything
from L1; you are doing this assignment functionally so values of variables are not supposed to change.
(Scheme does have a set! operation which will let you change the values of variables; do not use it; it is not
meant for such problems. Also do not use the sort function that is in the Scheme library. Going further, you
are to follow the blanket restriction of not using any built-in Scheme functions that we have not mentioned
in class.) Rather, the value returned by eliminateNsort will be a (new) list which will have all the
elements of L1, except those that appear in L2, and further, this list will be sorted.
Make sure that if some value x appears more than once in L1, then x appears the same number of times in
the result returned by eliminateNsort unless x also appears in L2 in which case it will not at all appear
in the result.
Test your function with several combinations of L1, L2 values (dont forget empty lists). You may find the
,trace command useful. It lets you trace a function everytime it is called. You can get help on the trace
command (as well as some other scheme48-specific commands) by using the ,help or ,? command
of scheme48. In preference to the ,load command, which does not display the results of evalutating the
last expression in the loaded file, you may wish to use the Scheme expression (load filename),
which does. (Here, filename could be something like testNonIntersectingLists.scm or
test2.scm.)
Approach: The trick to designing complex Scheme (or any other) programs is of course to define many
functions and to do as little as possible in each. If you follow this rule, you will find this assignment
reasonably straightforward to complete. To say that somewhat differently: do not try to do two things
in a function; if you do, you will likely get in trouble. So any time you find the need for computing
something that is somewhat different from the things that the functions you already have (or the one you are
currently defining) are capable of computing, introduce a new function rather than trying to add on that new
functionality to an existing function.
What to submit: You should submit a single file that contains the definitions of all your functions, including
the main one eliminateNsort. The file itself should be called myfns.scm. Do not use any other name
for the file or for the main function. Other functions that you define may have whatever names you choose.
To make it easy for your grader to find it, eliminateNsort should be the last function defined in your
Use white space appropriately so that your function definitions are easy to read. And include documentation
in the same file (NOT a separate README file). Comment lines in Scheme programs start with a semi-
Submit your lab by placing your file in the appropriate.
The grading system imposes a heavy penalty on late assignments: up to 24 hours late 10% off the score
received; up to 48 hours late 25% off; up to 72 hours late 50% off; more than 72 hours late forget it!
The lab you submit must be your own work. Minor consultation with your class mates is ok (ideally, any
such consultation should take place on the course discussion forum so that other students can contribute to
the discussion and benefit from the discussion) but the lab should essentially be your own work.
CS: assignmentchef QQ: 1823890830 Email: [email protected]
Reviews
There are no reviews yet.