After the fourth round, five more 4clojure.com solutions:
;;; Problem 45 - Intro to Iterate (deftest test-problem-45 (let [v1 [1 4 7 10 13] __ v1] (is (= __ (take 5 (iterate #(+ 3 %) 1)))))) ;;; Problem 44 - Rotate Sequence (deftest test-problem-44 (let [v1 (fn [n xs] (let [k (mod n (count xs))] (concat (drop k xs) (take k xs)))) __ v1] (is (= (__ 2 [1 2 3 4 5]) '(3 4 5 1 2))) (is (= (__ -2 [1 2 3 4 5]) '(4 5 1 2 3))) (is (= (__ 6 [1 2 3 4 5]) '(2 3 4 5 1))) (is (= (__ 1 '(:a :b :c)) '(:b :c :a))) (is (= (__ -4 '(:a :b :c)) '(:c :a :b))))) ;;; Problem 43 - Reverse Interleave (deftest test-problem-43 (let [v1 (fn [xs n] (partition (/ (count xs) n) (apply interleave (partition n xs)))) __ v1] (is (= (__ [1 2 3 4 5 6] 2) '((1 3 5) (2 4 6)))) (is (= (__ (range 9) 3) '((0 3 6) (1 4 7) (2 5 8)))) (is (= (__ (range 10) 5) '((0 5) (1 6) (2 7) (3 8) (4 9)))))) ;;; Problem 42 - Factorial Fun (deftest test-problem-42 (let [v1 #(apply * (range 1 (inc %))) __ v1] (is (= (__ 1) 1)) (is (= (__ 3) 6)) (is (= (__ 5) 120)) (is (= (__ 8) 40320)))) ;;; Problem 41 - Drop Every Nth Item (deftest test-problem-41 (let [v1 (fn [xs n] (apply concat (map #(take (dec n) %) (partition-all n xs)))) __ v1] (is (= (__ [1 2 3 4 5 6 7 8] 3) [1 2 4 5 7 8])) (is (= (__ [:a :b :c :d :e :f] 2) [:a :c :e])) (is (= (__ [1 2 3 4 5 6] 4) [1 2 3 5 6])))) (run-tests)