Looking for a way to generate a collection of return values from a function with side effects, so that I could feed it to take-while
.
(defn function-with-side-effects [n]
(if (> n 10) false (do (perform-io n) true)))
(defn call-function-with-side-effects []
(take-while true (? (iterate inc 0) ?)))
UPDATE
Here is what I have after Jan's answer:
(defn function-with-side-effects [n]
(if (> n 10) false (do (println n) true)))
(defn call-function-with-side-effects []
(take-while true? (map function-with-side-effects (iterate inc 0))))
(deftest test-function-with-side-effects
(call-function-with-side-effects))
Running the test doesn't print anything. Using doall
results in out of memory exception.