I am struggling to understand what Clojure is doing.  This is definitely a 
newbie question but I cannot figure it out :).  The question is best asked 
via a repl session:

[code]user=> (defn create-user [] {:id 1})
#'user/create-user
user=> (create-user)
{:id 1}
user=> (take 10 (repeatedly create-user))
({:id 1} {:id 1} {:id 1} {:id 1} {:id 1} {:id 1} {:id 1} {:id 1} {:id 1} 
{:id 1})
user=> (defn stream1 [] repeatedly create-user)
#'user/stream1
user=> (take 10 stream1)
IllegalArgumentException Don't know how to create ISeq from: user$stream1 
 clojure.lang.RT.seqFrom (RT.java:494)
user=> (take 10 (stream1))
IllegalArgumentException Don't know how to create ISeq from: 
user$create_user  clojure.lang.RT.seqFrom (RT.java:494)

user=> (defn stream2 [] (repeatedly create-user))
#'user/stream2
user=> (take 10 stream2)
IllegalArgumentException Don't know how to create ISeq from: user$stream2 
 clojure.lang.RT.seqFrom (RT.java:494)
user=> (take 10 (stream2))
({:id 1} {:id 1} {:id 1} {:id 1} {:id 1} {:id 1} {:id 1} {:id 1} {:id 1} 
{:id 1})
[/code]

My question is two parted - what is the different between stream1 and 
stream2 - what exactly do they return.  And, based on that, why doesn't 
(stream1) return a sequence.  In other words, what effect does wrapping the 
function body in quotes actually do?

I know I will kick myself when I get the answer, so please feel free to 
cause me to receive a good kicking ;).

Thanks!

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

Reply via email to