x $ y = x2 + y
where x, y are integers. Extend the definition of ``evaluate'' presented earlier to include the operators $ and / (normal division).
fib(n) = {fib(n-1) + fib(n-2) if n>1 } {1 if n=0 or n=1}Implement a recursive function to calculate the nth fibonacci number.
- 7.
- Write a function called ``merge,'' which takes two number-lists of equal length. It adds the corresponding members of each list and then returns the product of the resulting numbers.
For example,
(merge '(1 2 3) '(2 2 2))
should return 60, since (1+2)*(2+2)*(3+2)=60.
- 8.
- Will the following piece of code always terminate? Be careful to consider all possible cases.
(defun mystery (n) (cond ((= n 0) 0) (t (mystery (- n 1)))))
© Colin Allen & Maneesh Dhagat