user=> (def nums '(2 1 1 2 3 3 2 2 2 1))
#'user/nums
user=> (def sublists (partition-by identity nums))
#'user/sublists
user=> sublists
((2) (1 1) (2) (3 3) (2 2 2) (1))
user=> (reduce max (map count sublists))
3
user=> (doseq [numlist sublists]
(when (= (count numlist) (reduce max (map count sublists)))
(println numlist)))
(2 2 2)
nil
Having too much free time, that's a program of mine for calculating sine using Taylor's formula:
(defn fact [n]
(reduce * (take n (iterate inc 1))))
(defn sin-iteration [x n]
(/ (* (Math/pow -1 n)
(Math/pow x (+ (* 2 n) 1)))
(fact (+ (* 2 n) 1))))
(defn sin [x n]
(let [res (atom 0)]
(dotimes [iteration-counter n]
(swap! res #(+ (sin-iteration x iteration-counter) %)))
@res))
;;user=> (sin 0.52359 10)
;;0.4999924000896871