1 5/7: Functions on lists
Due: 5/7, midnight by email to dvanhorn.
Language: any.
You must complete this assignment individually and should not discuss solutions with anyone but the course staff.
1.1 Designing functions on lists of numbers
Design the following programs:
sum - sums a list of numbers.
sum-sqrs - sums the squares of a list of numbers.
interleave - from two lists of equal length, produces a single list of interleaved elements. For example, if given 1, 2, 3 and 4, 5, 6, it produces 1, 4, 2, 5, 3, 6.
closest-to-four - find the number closest to 4 in a given non-empty list of numbers.
arg-zero - given a function on numbers and a non-empty list of numbers, produce an element of the list for which the function gives a result closest to 0 when applied to that element. In other words, if given function f and list x_0, x_1, ..., x_n, then arg-zero should produce x_i (for some i in 0..n) where f(x_i) is as close to zero as any f(x_j), for all j in 0..n.
You may use any programming language you’d like, but your programs must be well-designed according to the design recipe.
1.2 Submissions
This is the only assignment that will be submitted via email. Please send an email with the following form:
Subject: 2510 Assignment 1 CCIS-username |
|
CCIS-username |
Full name |
|
Attach: source code |
where CCIS-username is your CCIS username. If you do not have a CCIS username or do not know what it is, please see the Systems group on the third floor of WVH immediately. Your source code should include your full name and CCIS username as well.