Next: About this document
Computer Science 3675
Summer 2000
Quiz 3
You have 25 minutes. Answer all of the questions.
- What is the value of Scheme expression
(car (cdr (cons 'horse (cons 'zebra ()))))?
- Write a Scheme function called drop so that (drop n L) returns
the result of removing the first n members from list L.
If L has fewer than n members, then (drop n L)
should return the empty list. For example, (drop 2 '(4 8
3 5 7)) = (3 5 7) and (drop 3 '(5 2)) = (). Be careful to use
Scheme syntax correctly.
- What part of a frame in the run-time stack allows a function
to find its nonlocal variables? (There is one small part that
gives a function access to the environment of its
creator. What is it called?)
- In the following C function definition, write an @
at each point where the compiler will insert an implicit
fetch. (That is, make all @ operations explicit. Each
variable stands for the variable, not the value of the variable.)
int test( int x)
{
int y, a[ 20];
y = x;
a[ y] = 40;
return a[ y];
}
- In C++, a function is represented as the address of
the machine-language code that performs that function. In
languages that allow a function to be defined inside
another function, that form
of representation of a function, by itself, is not adequate.
How is a function represented? What else is required in the
representation? What is the representation of a function called?
Karl Abrahamson
Mon Jun 19 13:39:37 EDT 2000