On Tue, Jan 18, 2011 at 12:22 AM, Nick Brown nwbr...@gmail.com wrote:
Hi, I'm wondering if there is a good way to test if a given sequence
is lazy, and if so, how much of it has been evaluated. I know the
fact that it is lazy should be transparent, but I'm thinking in the
context of unit
Testing for laziness seems simple:
(defn lazy? [coll]
(= (type coll) clojure.lang.LazySeq))
For instance if you know a particular sequence could be particularly
large or expensive in certain situations, you may want your tests to
assert that it is not getting evaluated prematurely..
That's
On Jan 18, 2011, at 6:16 AM, MiltondSilva wrote:
Testing for laziness seems simple:
(defn lazy? [coll]
(= (type coll) clojure.lang.LazySeq))
It's fairly easy to get other types that are (effectively) lazy. For example,
(cons 1 (map identity [1 2 3]))
is a clojure.Lang.Cons but I
On Jan 18, 2011, at 11:29 AM, Brian Marick wrote:
f this were my problem, I'd wonder if I could make the computation accept
functions. Then you could do something like this:
That was a lame solution except in the special case where the first element
must be computed. Here's a better
Hi, I'm wondering if there is a good way to test if a given sequence
is lazy, and if so, how much of it has been evaluated. I know the
fact that it is lazy should be transparent, but I'm thinking in the
context of unit testing knowing that could be valuable. For instance
if you know a particular