Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Vector-products/Clojure/vector-products.clj
Normal file
25
Task/Vector-products/Clojure/vector-products.clj
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
(defrecord Vector [x y z])
|
||||
|
||||
(defn dot
|
||||
[U V]
|
||||
(+ (* (:x U) (:x V))
|
||||
(* (:y U) (:y V))
|
||||
(* (:z U) (:z V))))
|
||||
|
||||
(defn cross
|
||||
[U V]
|
||||
(new Vector
|
||||
(- (* (:y U) (:z V)) (* (:z U) (:y V)))
|
||||
(- (* (:z U) (:x V)) (* (:x U) (:z V)))
|
||||
(- (* (:x U) (:y V)) (* (:y U) (:x V)))))
|
||||
|
||||
(let [a (new Vector 3 4 5)
|
||||
b (new Vector 4 3 5)
|
||||
c (new Vector -5 -12 -13)]
|
||||
(doseq
|
||||
[prod (list
|
||||
(dot a b)
|
||||
(cross a b)
|
||||
(dot a (cross b c))
|
||||
(cross a (cross b c)))]
|
||||
(println prod)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue