Perfect! Thanks! On Oct 25, 7:10 pm, Alan Malloy <a...@malloys.org> wrote: > (take-while (complement nil?) (repeatedly myfunc)) > > On Oct 25, 4:07 pm, rugby_road <cabjh...@embarqmail.com> wrote: > > > > > > > > > I have a function without arguments which returns a big,complex object > > repeatedly until it returns nil. That is to say that the function > > will produce a sequence of objects, but I don't know how many. I want > > to call the generator as a lazy sequence but how do I make such a > > thing? > > > Currently I am doing something like this: > > > (loop [i (myfunc)] > > (if (nil? i) nil ;; we are done here > > (let > > ...do a bunch of stuff to i > > (recur (myfunc))) > > > This works okay, but leaves that recur statement dangling at the end > > of the routine. What I would like to do is the cleaner: > > > (doseq [ i (myseq)] > > ...do a bunch of stuff to i) > > > I have tried using (def myseq (repeatedly (myfunc))), but the > > repeatedly doesn't seem to ever end. I have tried having myfunc > > return a nil, or a [] but it just keeps repeating the final end value > > of nil or []. > > > How would you make such a terminating sequence? > > Is there a special final value myfunc must return so that the sequence > > ends gracefully? > > Or is this just an abuse of the concept of a sequence and I should > > just stick to the loop? > > > thanks > > Blake
-- 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