Thank you all so much!! As always, I learn a lot from this forum.
On May 18, 12:50 am, Jarkko Oranen chous...@gmail.com wrote:
On May 18, 2:23 am, Base basselh...@gmail.com wrote:
(defn lazy-date-seq [d1 d2]
(let [start (- d1
(.dayOfMonth)
Hi All -
I am trying convert a function to use loop/recur and am getting the
dreded
java.lang.UnsupportedOperationException: Can only recur from tail
position (repl-1:414) error
(at least dreded for newbies...)
The function takes 2 joda dates and returns a sequence of dates
starting at the
Thanks Mike -
So I was doing a little more digging on this and came across an
interesting blog posting:
http://formpluslogic.blogspot.com/2009/07/clojure-lazy-seq-and-recursion.html
discussing the use of recursion vs lazy sequences.
To mimic Brent from his posting I created 2 fn's:
(defn
Note that your recur call is wrapped in a cons. It is *not* in the
tail position.
(def date-seq
(fn [d1 d2]
(loop [b (- d1
(.dayOfMonth)
(.withMinimumValue))
e d2]
(cons b (if (time/before? b e)
(recur (.plusMonths b 1) e)) ;; Inside
Hi Base,
It's useful to think of the pattern of loop/recur and then apply it
to your problem. I.e
(loop [-- initial bindings --]
(if --- terminating condition ---
---return result---; otherwise...
(do-stuff with bindings
(recur ---with new bindings---
A simple
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
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)