Fork me on GitHub
#beginners
<
2015-12-27
>
kopasetik06:12:28

@sllyq: Thanks for your answer! simple_smile

christopherbui21:12:38

@kopasetik: @sllyq: Your version of dot product can be written like so:

(defn dot-product [vector1 vector2]
                            (apply + (map * vector1 vector2)))
There's no need to wrap * in an anonymous fn

christopherbui21:12:40

@kopasetik: I think you have a bug in your digits fn. I think you want a >= 10 or > 9.

(defn digits
  ([n] (digits n []))
  ([n digits]
   (let [digits (conj digits (mod n 10))]
     (if (> n 9)
       (recur (quot n 10) digits)
       digits))))

(defn dot-product
  [v1 v2]
  (reduce + (map * v1 v2)))

;; Not sure what this fn was supposed to do
(defn tens-by-13
  [length]
  (map-indexed (fn [i ten]
                 (mod (Math/pow ten i) 13))
               (take length (repeat 10))))

(defn foo
  [n]
  (let [digits (digits n)
        remainder-series (tens-by-13 (count digits))]
    (dot-product digits remainder-series)
    ))
If you get me more details and need some more help just ping me!

kopasetik23:12:58

@christopherbui: Thanks!