What is the best way to remove the duplication in these two functions?:

(defn- next-day-of-week-in-future [day-num]
  (find-first #(= day-num (.. % dayOfWeek get)) (today+all-future-dates)))


(defn- next-day-of-month-in-future [day-of-month]
  (find-first #(= day-of-month (.. % dayOfMonth get)) (today+all-future-dates)))

;; Here (today+all-future-dates) is a seq of DateMidnight objects from joda time

I tried to do something like this - but it failed due to my lack of
understanding:

(defn- next-day-of-period [period day-of-period]
  (find-first #(= day-of-period (.. % period get)) (today+all-future-dates)))

(def ^{:private true} next-day-of-week-in-future (partial
next-day-of-period 'dayOfWeek))

(def ^{:private true} next-day-of-month-in-future (partial
next-day-of-period 'dayOfMonth))

 No matching field found: period for class org.joda.time.DateMidnight

Is this kind of thing possible?  Are the interop macros or #() macro
interfering? I'd love to understand this bit a bit better.

Thanks,
Alex

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