|
CS 3721, Spring 2004 |
Recitation 11 must be sent by email
following directions at: email submissions on or before
|
Trying out recursion in C/C++/Java:
(defun addvec (list) (cond ((null list) 0) (t (+ (car list) (add (cdr list)))) ))along with vecmul above to define an inner product function innprod. [For example, (innprod '(1 2 3) '(7 8 9)) returns 1*7 + 2*8 + 3*9 or 50. Hint: this is very easy.]
> (mapcar '1+ '(1 2 3)) > (mapcar '+ '(1 2 3) '(8 10 12)) > (mapcar '* '(1 2 3) '(8 10 12)) > (mapcar 'car '((a b c) (x y z) (r s t))) > (mapcar 'cdr '((a b c) (x y z) (r s t))) > (apply '+ '(2 4 6 8)) > (apply '* '(1 2 3 4 5)) > (apply 'list '(a b c d))
(defun innprod (x y) (apply '+ (mapcar '* x y)) )
Contents of submission
for Recitation 11: Last Name, First Name; Course Number; Recitation Number. Answers to questions 1 through 10 above.
|