CSE 341 -- Programming Languages
Autumn 2002
|
Department of Computer Science and Engineering,
University of Washington
Steve Tanimoto (instructor)
|
Assignment
1
Version 1.00 of Sept 30 |
Introduction to Scheme
Due date and time: Thursday, October 10,
2002 (at the beginning of section).
Turn in this assignment as a hardcopy printout. |
Title: Introduction to Scheme.
Purposes: Learn to use Scheme syntax,
built-in procedures, how to define recursive functions,
understand Scheme evaluation, and how to manipulate list structures.
Instructions: Read Chapters 1-12
in
Scheming on the Web
and do the following exercises:
- Chapter 2, number 2.
- Chapter 3, number 1 (a-f).
- Chapter 4, number 2 (a-d).
- Chapter 6, numbers 1 and 3.
- Chapter 7, numbers 1, 3, and 5.
- Without using Scheme's
built-in function REVERSE, write a recursive function
MY-REVERSE that takes a list and returns a new list
in which the top-level elements are in reverse order.
Demonstrate your function on the list (A B C D) as well as a list
of your own choosing.
- In this exercise, we'll explore
"deep" processing of data.
Again without using Scheme's
built-in function REVERSE, write a recursive function
DEEP-REVERSE that takes a list and returns a new list
in which not only the top-level elements are in reverse order,
but any sublists have been reversed as well. Any sub-sublists should
be reversed, too, etc.
Demonstrate your DEEP-REVERSE function on two examples, one of which
is the list below and the other of which you make up yourself. Your
example should contain at least one sublist with at least three elements.
(THIS ILLUSTRATES (1 2 (3 4 5) 6 7) OK)
- Now let's work on a translation problem.
Write a recursive function SPELL-NUMBERS that will take a list
as its argument and process it as follows. The list will
represent a sentence, such as (JOHN HAD 3 BAGS EACH CONTAINING 5 BALLS).
Your procedure will return a new list
in which each occurrence of a number has
been replaced by its word equivalent.
It should handle integers 0 through 10.
In this example, the result would be (JOHN HAD THREE BAGS EACH
CONTAINING FIVE BALLS).
Demonstrate your function on this example and an example of
your choice that involves five numbers.
Individual Work: This assignment
requires individual work. Do NOT work in teams on this assignment.