As Lauren Petit points out, you need the macro to define the whole
desired result. Something like this should do it:
(defmacro defautoroutes [name & paths]
(let [getps (for [p paths] `(GET ~(str "/" p) (foo ~p)))]
`(defroutes ~name ~...@getps)))
(defautoroutes all-routes "one" "two" "three")
On May 6, 10:21 pm, Micah Martin <[email protected]> wrote:
> Hey all,
>
> I'm having trouble writing a macro and I hoping some one here can help. My
> desired result is the following:
>
> (defroutes all-routes
> (GET "/one" (foo "one"))
> (GET "/two" (foo "two"))
> (GET "/three" (foo "three")))
>
> But I'd like to write it like so:
>
> (defroutes all-routes
> (make-foos "one" "two" "three"))
>
> How do I write make-foos? Does if have to be a macro, or can it be a
> function?
>
> Thanks,
>
> Micah
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group
> athttp://groups.google.com/group/clojure?hl=en
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en