What about this? First, use :title and :body keywords instead of
"title" and "body" strings as keys in form-params. Then define this
utility function:

(defn get-seq [m & kws]
  ((apply juxt kws) m))

which takes a map and one or more keywords (cannot be other types of
key) and returns a seq (actually a vector) of the corresponding
values, in order; do this

(defn new-article [path timestamp title body]
  (Article. path title body timestamp))

so you can use apply. And then this:

(defn save-article
  [path form-params timestamp]
  (ds/save!
    (apply new-article path timestamp
      (get-seq form-params :title :body))))

is neat and tidy and easily extensible to added form-params later (add
them to the end of new-article's arg list and to the get-seq keyword
list in the same order; pass them to the amended Article constructor
appropriately).

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