Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,20 @@
(defn dot-product [& matrix]
{:pre [(apply == (map count matrix))]}
(apply + (apply map * matrix)))
(defn dot-product2 [x y]
(->> (interleave x y)
(partition 2 2)
(map #(apply * %))
(reduce +)))
(defn dot-product3
"Dot product of vectors. Tested on version 1.8.0."
[v1 v2]
{:pre [(= (count v1) (count v2))]}
(reduce + (map * v1 v2)))
;Example Usage
(println (dot-product [1 3 -5] [4 -2 -1]))
(println (dot-product2 [1 3 -5] [4 -2 -1]))
(println (dot-product3 [1 3 -5] [4 -2 -1]))