Reputation: 58
I was wondering if clojure has something built-in for the following code.
I know I can do (map (fn [x] (f x)) coll)
and then evaluate the sequence as done here. I don't want to do that.
(defn apply-to-all [f coll]
(f (first coll))
(if (= (count (rest coll)) 0)
nil
(apply-to-all f (rest coll))))
"example usage"
(apply-to-all println [0 1 2])
Upvotes: 1
Views: 70