... the printing mechanism, always lags a seq's evaluation ... (fastidiuos flounder)

11 views
Skip to first unread message

JuanManuel Gimeno Illa

unread,
Sep 29, 2012, 5:37:19 AM9/29/12
to fp...@googlegroups.com
"That is, it won't print the first element before it has asked for the second."

I think the blame of these two evaluations is in the construction (loop [[x & xs] xs ....) that exists in the function print-sequential. The [x & xs] destructuring forces the evaluation of two elements of the original xs sequence. 

A simpler example of this, I think, would be:

user=> (defn spy [] (lazy-seq (print "*") (cons 1 (spy))))
#'user/spy

user=> (def s (spy))
#'user/s

user=> (let [[f & r] (take 4 s)] f)
**1

I hope this is the answer, but I'm not 100% sure.

Juan Manuel 
Reply all
Reply to author
Forward
0 new messages