Solved by wrapping iterate on take-while :) (defn tokens-sec [string] (take-while identity (iterate (fn [[_ _ string :as info]] (if (> (count string) 0) (next-token info))) [0 0 string []])))
--- Wilker LĂșcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Fri, Sep 2, 2011 at 3:46 PM, Wilker <wilkerlu...@gmail.com> wrote: > Hi guys, > > I'm writing a simple parser here, and for parsing I'm creating a > lazy-sequence this way: > > (defn tokens-sec [string] > (iterate (fn [info] (next-token info)) [0 0 string []])) > > but there is a problem, this sequence has a limit (that's when there are no > more tokens to consume). > How I stop the iteration?? How I signal that it reached the end? I tried: > > (defn tokens-sec [string] > (iterate (fn [[_ _ string] :as info] > (if (> (count string) 0) (next-token info))) [0 0 string []])) > > but no lucky... > > There is any way to signal to iterate that list reached the end? Or there > is another way that I can't see to make this lazy list works this way? > --- > Wilker LĂșcio > http://about.me/wilkerlucio/bio > Kajabi Consultant > +55 81 82556600 > > -- 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