Run several test cases for filter-2 that was
defined in the reading. What is the fewest number of parameters
that may be provided?
Explain your results.
Develop a procedure named acronym that takes any number of
non-null strings as arguments and returns one string consisting of the
initial characters of those strings, thus:
> (acronym "Mothers" "Against" "Drunk" "Driving")
"MADD"
Develop a procedure named call-arity that takes any number of
arguments and returns the number of arguments it received (ignoring their
values):
> (call-arity 'a #\b "c" '(d)) 4 > (call-arity 0.0) 1 > (call-arity) 0
Define and test a procedure clicker that takes one or more
arguments, of which the first must be an exact integer and each of the
others must be either the symbol 'up or the symbol
'down. Clicker should start from the given
integer, add 1 for each 'up argument, subtract 1 for each
'down argument, and return the result:
> (clicker 17 'up 'up) 19 > (clicker -12 'down 'up 'down 'down 'down) -15 > (clicker 100) 100
Write a procedure increasing? which takes one or more numbers
as parameters and returns true if the numbers are in increasing order.
Thus, increasing? is a user-defined version of the built-in
Scheme procedure <. In your code, you may use
< to compare two numbers, but not more than two numbers at
a time. Here are a few test cases and their desired results:
>(increasing? 2) #t >(increasing? 2 6 10 24 129) #t >(increasing? 6 2 10 24 129) #f >(increasing? 2 6 10 129 24) #f
Write a procedure that finds the average of a sequence of numbers.
Thus, (average 3 5 7 11 14) should return 8.
Note: An average makes sense only if we have at least one number.
This document is available on the World Wide Web as
http://www.cs.grinnell.edu/~walker/courses/151.sp04/labs/variable-arity.xhtml
created March 22, 1997
last revised March 9, 2004
Henry Walker (walker@cs.grinnell.edu), John David Stone (stone@cs.grinnell.edu), and Ben Gum (gum@cs.grinnell.edu)