Use doseq
and you are all set. For instance:
(doseq [e '(1 2 3)] (prn e))
It will be printed:
1 2 3 nil
EDIT:
If you want to implement for-each
manually and using as many special forms as possible, here is another alternative, although it ends up almost as short as yours:
(defn for-each [fl] (cond (empty? l) nil :else (do (f (first l)) (recur f (rest l)))))
Interestingly, the same procedure could be written more briefly in Scheme, the Lisp dialect used in SICP:
(define (for-each fl) (cond ((null? l) null) (else (f (first l)) (for-each f (rest l)))))
source share