Hi,

On Wed, May 05, 2010 at 08:17:51AM -0700, Robert Luo wrote:

> > repeated-seq cannot do anything about the problem. You have to ensure
> > that your f is free of "overlap" (so to say). One way todo that in
> > your example is (repeated-seq #(-> % inc (range 5)) -1).
> 
> In my example function, f could avoid overlapping by itself. But
> sometimes the underlying f is difficult to ensure that, and my
> intention is to let repeated-seq to do it rather than leave it to it's
> client.

I think this is the wrong way to go. As it stands repeated-seq might be
a useful function. It cannot know what is overlap and what is not. The
function f must to care of that. Subsequent equal values does not
necessarily mean overlap of some kind. If it is the case for your f,
then you can still filter the resulting seq through distinct or some
uniq style filter.

(defn uniq
  [coll]
  (lazy-seq
    (when-let [s (seq coll)]
      (let [f (first s)]
        (cons f (uniq (drop-while #(= % f) (rest s))))))))

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