I’ll second what Timothy Baldridge <tbaldri...@gmail.com> wrote.  By the way, 
you have to make sure you’re dealing with some sort of clojure.lang.IPending 
before you call realized? on it.  

I prefer to test against interfaces rather than concrete classes so I would try 
something like this (minimally tested):

(defn lazy-seq? [x]
  (and (instance? clojure.lang.IPending x) (seq? x) (not (realized? x))))

Even after a lazy seq has been “realized” (typically with doall), it’s still a 
clojure.lang.LazySeq but the results have been cached so it’s not so “lazy” 
anymore.

Depending on what you’re doing, you might get by with just counted? which is 
true for literal lists and vectors, but false for conses and lazy collections.



> On Oct 18, 2015, at 5:55 PM, Brian Marick <mar...@exampler.com> wrote:
> 
> Is there a way to tell if `v` is a lazyseq other than `(instance? 
> clojure.lang.LazySeq v)`? Seems like there should be, but I'm not seeing it.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to