Re: Testing if a sequence is lazy

2011-01-19 Thread Chouser
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

Re: Testing if a sequence is lazy

2011-01-18 Thread MiltondSilva
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

Re: Testing if a sequence is lazy

2011-01-18 Thread Brian Marick
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

Re: Testing if a sequence is lazy

2011-01-18 Thread Brian Marick
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

Testing if a sequence is lazy

2011-01-17 Thread Nick Brown
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