Computer Science 433
Programming Languages
Fall 2012, The College of Saint Rose
Lecture 13: Recursion and More in Scheme
Date: Monday, October 15, 2012
Agenda
- Announcements
- Looking ahead to our exam
- In class Monday, October 29, with a take home component due
back Wednesday, October 31
- Will cover topics up through class on Monday, October 22
- More details next Monday
- Program/Problem Set 5 discussion
- Writing Scheme functions
- Recursion, recursion, recursion
- Functions as parameters
Lecture Assignment 13
Due at the start of class, Wednesday, October 17.
Please submit answers to these questions
either as a hard copy (typeset or handwritten are OK) or by email to
terescoj AT strose.edu by the start of class. Please use a clear subject line
when submitting by email (e.g., CSC 433 Lecture
Assignment 13, Joe Student). We will discuss these
questions at the start of class, so no late submissions are
accepted.
- 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)
Examples
- cons2
- elements2
- factorial
- listem
- remove_all
- add1_num
- extract_numbers
- insertion_sort
- general_insertion_sort