Hi, On May 18, 1: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)))))) Yes. This is more or less the way lazy-seq is used. However I would move the check outside the cons. Then you get an empty sequence if d1 is initially after d2. This would seem as a reasonable behaviour. (Now you get a sequence containing d1.) Also a one-branched if is usually written as when. (defn date-seq [d1 d2] (let [start (-> d1 .dayOfMonth .withMinimumValue)] (lazy-seq (when (joda/before? start d2) (cons start (date-seq (.plusMonths start 1) d2)))))) I don't see why transforming this into a TC form should bring any benefit. The only reason I can think of is a performance optimisation. Then see Adrian's answer. Although not your question: In this case you also easily use Clojure's seq library to get your sequence. (defn date-seq [d1 d2] (let [start (-> d1 .dayOfMonth .withMinimumValue)] (take-while #(joda/before? % d2) (iterate #(.plusMonths % 1) start)))) 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