Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Sequences by
retagged by

seque's documentation says:

The queued seq will produce a concrete seq in the background, and can
get up to n items ahead of the consumer.

It seems to force n+2 items ahead of the consumer.

(let [producer (fn step [i]
                 (lazy-seq
                   (prn "producer" i)
                   (cons i (step (inc i)))))
      s (seque 1 (producer 0))]
  (Thread/sleep 1000)
  nil)
;="producer" 0
;="producer" 1
;="producer" 2
nil

1 Answer

0 votes
by
selected by
...