This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-27
Channels
- # admin-announcements (9)
- # aws (1)
- # beginners (4)
- # boot (197)
- # cider (38)
- # cljsrn (70)
- # clojure (128)
- # clojure-russia (36)
- # clojurecup (1)
- # clojurescript (86)
- # core-typed (2)
- # css (1)
- # datomic (35)
- # editors-rus (4)
- # hoplon (22)
- # ldnclj (2)
- # mount (19)
- # off-topic (45)
- # om (63)
- # onyx (7)
- # parinfer (8)
- # yada (2)
@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@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!@christopherbui: Thanks!