Computer Science 433
Programming Languages
Fall 2014, The College of Saint Rose
Lecture 9: More Scheme
Date: Wednesday, September 24, 2014
Agenda
- Announcements
- Program/Problem Set 4: Parser for Little C [HTML] [PDF] due next week
- Lecture 8 assignment recap
- A look back at the Scheme functionality from last time
- More on Scheme lists
- Writing Scheme functions
- Recursion, recursion, recursion
Lecture 9 Assignment
Due at the start of class, Monday, September 29.
Please submit answers to these questions
in Submission
Box under "LA9" or in hard copy by the
start of our next class. We will discuss these questions at the
start of class, so no late submissions are accepted. Please be sure
that your name is clearly indicated in all submissions.
- Write a Scheme function add_article which takes a noun as
its parameter and returns a list containing the word the and
the noun. (4 points)
- Write a function snoc which takes a list and an atom as its
arguments. snoc returns the list with the atom tacked onto the
end. (5 points)
For example, the function call
(snoc '(this assignment is really) 'fun)
would return the list
(this assignment is really fun)
- Write a function list_three_sentences which takes a noun
and a list of three verbs as its parameters. It returns a list
containing three sentence lists. Use add_article and
snoc in your definition. (5 points)
For example, the function call
(list_three_sentences 'aardvark '(ate flies screamed))
would return the list
((the aardvark ate) (the aardvark flies) (the aardvark screamed))
- Write a function slope that takes two arguments which
contain the x and y coordinates (the coordinates of one point in
each list) of two points. slope should return the slope of the
line connecting the points. (4 points)
- Write a function reverse that takes a list as its parameter
and returns a list with the same elements but in reverse order. (4
points)
Terminology
Examples
- cons2
- elements2
- factorial
- listem
Links