# Lazy look and say sequence

I have been solving a set of online Clojure problems. One of them involves the look and say sequence.

(defn look-and-say [s]
(let [las (loop [item (first s) coll s counts [] count 0]
(cond
(nil? (seq coll)) (conj counts count item)
(= item (first coll)) (recur item (rest coll) counts (inc count))
:else  (recur (first coll)  coll (conj counts count item) 0)))]
(lazy-seq (cons las (look-and-say las)))))


I would like know what I did right and what I could do better. Any feedback is welcome.

• partition-all the seq into groups of consecutive numbers
• for each group of consecutive numbers say how many there are (map say list-o-groups)
• flatten the result into one list. but really you should use mapcat in the previous step and skip this step.
• apply the the result to the same function (the iterate function)
• take as many of these as you need
• Bluggghhhhh map followed by flatten is vile, don't recommend it. Just use mapcat. – amalloy Sep 2 '11 at 22:57