I'm just a Clojure noob (started learning yesterday). Here is my helloworld program. It factorizes number into primes. Do you have any comments? How could I make this code cleaner and shorter? Maybe I can deduplicate some things?
(defn lazy-primes
([] (cons 2 (lazy-seq (lazy-primes 3 [ 2 ]))))
([current calculated-primes]
(loop [ [first-prime & rest-primes] calculated-primes]
(if (> (* first-prime first-prime) current)
(cons current (lazy-seq (lazy-primes
(inc current)
(conj calculated-primes current))))
(if (= 0 (mod current first-prime))
(lazy-seq (lazy-primes (inc current) calculated-primes))
(recur rest-primes))))))
(defn factorize
([num] (factorize num '(1) (lazy-primes)))
([num acc primes]
(if (= num 1) acc
(loop [ [head & rest] primes ]
(if (= 0 (mod num head))
(factorize (/ num head) (cons head acc) primes)
(recur rest))))))