commit 1e6de8943d87aab3b5abbb66a54c56fd364300ba
parent 432903f87525fa4c2428917cf6564ab428b300b7
Author: Ed van Bruggen <edvb@uw.edu>
Date: Mon, 16 Dec 2019 02:04:00 -0800
Add list dot product function
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/tibs/lib.tsp b/tibs/lib.tsp
@@ -233,6 +233,12 @@
(define (even? x) (= (mod x 2) 0))
(define (odd? x) (= (mod x 2) 1))
+(define (dot x y)
+ (if x
+ (+ (* (car x) (car y))
+ (dot (cdr x) (cdr y)))
+ 0))
+
(define (! n)
(if (= n 1)
1