On May 18, 2:23 am, Base <basselh...@gmail.com> wrote:

> (defn lazy-date-seq [d1 d2]
>   (let [start (-> d1
>                 (.dayOfMonth)
>                 (.withMinimumValue))]
>      (lazy-seq
>        (cons start
>          (if (joda/before? start d2)
>            (lazy-date-seq (.plusMonths start 1) d2))))))
>
> The lazy version worked like a champ and appears (to me) to be more in
> the vain of Lisp (with a touch of Haskell).
> Is the author of the blog correct about using lazy seq in this way?
> Assuming that he is correct and I converted date-seq to a loop/recur
> format to use TCO, would one of these be preferable over the other in
> terms of idiomatic clojure?

The lazy version is more idiomatic. By default, you should make
sequences lazy unless there is a compelling reason to do otherwise.

In this case it also avoids the stack building problem that the
recursive version has.

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