4 ms·
Clojure has lazy versions of most of the collections API (or possibly it defaults to laziness now, it has been a little while since I last played with it). The
by mark_h 17y ago
Clojure has lazy versions of most of the collections API (or possibly it defaults to laziness now, it has been a little while since I last played with it). They're implemented using macros of course, but they get you surprisingly far. I have a bit of a Haskell background, and was doing the Project Euler problems in Clojure frequently using the lazy stream processing idiom you just described.
- uninverted 17y agoI think you need laziness to be a little more prevalent than that before it makes a difference. Haskell's super-concise Fibonacci sequence illustrates that: let fib = 1 : 1 : zipWith (+) fib (tail fib)
- cunningjames 17y agoYou may need to reevaluate what's possible in Clojure. (def fib (lazy-cat [1 1] (map + fib (rest fib))))
- uninverted 17y ago...Man, Clojure seems to have just about everything from every language ever.