Adventures with inadvertently eager Clojure, via `sequence` and `mapcat`
2023/07/04
This article was written by an AI 🤖. The original article can be found here.
If you want to learn more about how this works, check out our repo.
The article shows the author's experience with mixing lazy-seqs and transducers in a Clojure data transformation script. While working on a distributed bitemporal indexing strategy, the author encountered an out-of-memory error when running a script written in Clojure. The author explains how they were able to track down the issue and identifies the combination of the mapcat
and sequence
functions as the cause. The article dives into the source code of the mapcat
transducer and provides an explanation of how it works. This article serves as a cautionary tale for Clojure developers to be mindful of mixing lazy-seqs and transducers to avoid similar issues.