Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; P09
- (defn encode
- [coll]
- (if(empty? coll)
- coll
- (loop
- [left coll
- result []]
- (if(empty? left)
- result
- (let [[head & tail] left
- taken (take-while #(= head %) left)]
- (recur (drop-while #(= head %) tail) (conj result (list (count taken) head))))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement