Ex1.5 ベクトルの内積

ベクトルの内積を求める問題。
applyとmapcarですっきり定義できた。

;;; exercise 1.5 [m] Write a function to compute the dot product of two sequences
;;; of numbers, represented as lists. The dot product is computed by multiplying
;;; corresponding elements and then adding up the resulting products. Example:
;;;  (dot-product '(10 20) '(3 4)) => 10 * 3 + 20 * 4 => 110
(defun dot-product (s1 s2)
  (apply #'+ (mapcar #'* s1 s2)))

(dot-product '(10 20) '(3 4))
;; => 110 (#x6E, #o156, #b1101110)