Hi,

On Jan 28, 5:21 am, free_variation <cane.c...@gmail.com> wrote:

> Is the solution to have my-seq somehow
> refer to the next element to be retrieved, i.e. to the head of the
> infinite sequence that has yet to be fed to the workers?

You probably want a Ref here to coordinate the changes on the
sequence.

(defn get-step
  [queue]
  (dosync
    (let [q @queue]
      (alter queue rest)
      q)))

; Or for convenience if you like...
(def get-step-c
  (let [queue (ref your-seq-here)]
    (partial get-item queue)))

Each worker can call get-step on your seq Ref. Then the current step
in the seq is returned and the Ref is updated to contain the next
step. The seq is returned, so you can do nil-checking of (seq q) or
working with (first q) and what you normally do with seqs.

Sincerely
Meikel

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