- [5 points]
Write a function (incr1 lst) that adds 1 to each element of a list of numbers.
It should work like this:
(incr1 '(5 10 17)) = (6 11 18)
(incr1 '(-5 7)) = (-4 8)
(incr1 '()) = NIL
[5 points]
Write a function (add2even n lst) that adds a given number n to each
even number in a list of numbers. You can use the system defined
predicate (evenp n) to check if a number is even.
It should work like this:
(add2even 2 '(5 10 17)) = (5 12 17)
(add2even 3 '(10 0 -17)) = (13 3 -17)
(add2even 3 '()) = NIL
- [5 points]
Write a function (enumerate n) that returns a list containing the
integers from n to 0 (extremes included). Assume that n is positive.
It should work like this:
(enumerate 3) = (3 2 1 0)
(enumerate 0) = (0)
- [5 points]
Write a procedure (add-square-odd n) that adds the square of the
odd integers from 0 to n. Assume n is a positive integer.
It should work like this:
(add-square-odd 6) = 35 ; since 1+(3*3)+(5*5)=35
(add-square-odd 5) = 35 ; since 1+(3*3)+(5*5)=35
(add-square-odd 3) = 10 ; since 1+(3*3)=10