After the third round, five more 4clojure.com solutions:
(ns com.icyrock.clojure.a4clojure_com.core (:use clojure.test)) ;;; Problem 40 - Interpose a Seq (deftest test-problem-40 (let [v1 #(rest (interleave (repeat %) %2)) __ v1] (is (= (__ 0 [1 2 3]) [1 0 2 0 3])) (is (= (apply str (__ ", " ["one" "two" "three"])) "one, two, three")) (is (= (__ :z [:a :b :c :d]) [:a :z :b :z :c :z :d])))) ;;; Problem 39 - Interleave Two Seqs (deftest test-problem-39 (let [v1 #(mapcat list % %2) __ v1] (is (= (__ [1 2 3] [:a :b :c]) '(1 :a 2 :b 3 :c))) (is (= (__ [1 2] [3 4 5 6]) '(1 3 2 4))) (is (= (__ [1 2 3 4] [5]) [1 5])) (is (= (__ [30 20] [25 15]) [30 25 20 15])))) ;;; Problem 38 - Maximum value (deftest test-problem-38 (let [v1 #(first (sort > %&)) __ v1] (is (= (__ 1 8 3 4) 8)) (is (= (__ 30 20) 30)) (is (= (__ 45 67 11) 67)))) ;;; Problem 37 - Regular Expressions (deftest test-problem-37 (let [v1 "ABC" __ v1] (is (= __ (apply str (re-seq #"[A-Z]+" "bA1B3Ce ")))))) ;;; Problem 36 - Let it Be (deftest test-problem-36 (do (is (= 10 (let [x 7 y 3 z 1] (+ x y)))) (is (= 4 (let [x 7 y 3 z 1] (+ y z)))) (is (= 1 (let [x 7 y 3 z 1] z))))) (run-tests)