i'm new to clojure and functional programming so i would appreciate some help. :)
What i'm trying to do is : I'm trying to get this [1 1 2] from this "structure" [[1 0 1] [0 1 0] [0 0 1]] therefore i'm trying to sum first elements of the three vectors, second elements of the three vectors and finally third elements of the three vectors to get a new vector in the end containing this sums.
My code is the following:
(def matrix [[1 0 1] [0 1 0] [0 0 1]])
(def sum (atom 0))
(def sum-vector (atom []))
(for [i (range 3)]
((for [j (range (count matrix))]
(reset! sum (+ @sum (nth (nth matrix j) i)))
)
(reset! sum-vector (conj @sum-vector @sum))
(reset! sum 0)
))
But i get this exception : clojure.lang.LazySeq cannot be cast to clojure.lang.IFn ... What i'm i doing wrong?