The docstring for iterate says that it returns a lazy sequence, but it 
returns a Cons wrapped around a LazySeq.  This means, for example, that 
realized? can't be applied to what iterate returns.  Is this a problem with 
the iterate docstring?  Or should realized? be applicable to Conses?  I 
assume that there's a good reason that iterate returns a Cons instead of a 
LazySeq.

Clojure 1.6.0
user=> (doc iterate)
-------------------------
clojure.core/iterate
([f x])
  Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of 
side-effects
nil

user=> (def xs (iterate inc 0))
#'user/xs

user=> (class xs)
clojure.lang.Cons

user=> (class (rest xs))
clojure.lang.LazySeq

user=> (realized? (rest xs))
false

user=> (realized? xs)
ClassCastException clojure.lang.Cons cannot be cast to 
clojure.lang.IPending  clojure.core/realized? (core.clj:6883)

user=> (take 5 xs)
(0 1 2 3 4)

user=> (realized? (rest xs))
true

user=> (realized? xs)
ClassCastException clojure.lang.Cons cannot be cast to 
clojure.lang.IPending  clojure.core/realized? (core.clj:6883)

user=> (doc realized?)
-------------------------
clojure.core/realized?
([x])
  Returns true if a value has been produced for a promise, delay, future or 
lazy sequence.
nil

-- 
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