I think you just forgot to return the value itself. This seems to work: (defn produce [value predicate generator] (when (predicate value) (let [result (generator value)] (cons result (lazy-seq (produce result predicate generator))))) )
And I would use "quot" instead of "unchecked-divide", but maybe I did not understand your intention fully: user=> (produce 1337 #(> % 0) #(quot % 2)) (668 334 167 83 41 20 10 5 2 1 0) On Jun 27, 2:23 am, _hrrld <hhaus...@gmail.com> wrote: > Hi, > > I'm trying to use lazy-seq to implement a cool piece of functionality > I saw in the Factor programming language. Here is the documentation > for that > functionality:http://docs.factorcode.org/content/word-produce,sequences.html > > I think a lazy version of Factor's "produce" word would be super- > powerful for some of the things I'm working on. > > This is the first time I've tried to create my own lazy sequence, so > don't laugh. > > Here is my attempt:http://gist.github.com/136825 > > For some reason, the lazy sequence that is returned is always empty > (?) or at least seems that way. > > Am I doing something silly? Or perhaps I've misunderstood lazy-seq's > operation. > > Thanks in advance for any advice, > -Harold --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---