No. (doall (map ..)) not your only choice: mapv not lazy, so it effectively performs (doall (map ..)) , but in one operation.
It’s nice to use either map or mapv with a display function that creates side effects. Instead, try using doseq , which clearly indicates side effects. As you point out, and this concerns the main problem, the problem with doseq is that the return results are not gathered together for you in the sequence as they are with map or mapv .
If you don’t need a lazy sequence, try not to produce it first, not to produce it, and then make it realize how you are doing now. Therefore, we must eliminate the use of map .
Most cases where you do not need laziness are covered with mapv , when your map function does not affect side effects, or doseq when it is, but does not return a result.
If your map function produces a result and is a side effect, and you want these results to be put together, the best option would be to use mapv over the map function, which is called as explicitly creating a side using a name ending in ! . Although it’s not very convenient to use mapv , at least ! clearly emphasizes what is happening.
source share