Almost, but you do need to resolve the symbols to functions when you
evaluate the operation:

(defn arith [x y]
  (map (fn [op] [((resolve op) x y) (list op x y)]) '[+ - / *]))

Regards,
Stuart

On 16 March 2012 02:52, Jack Moffitt <j...@metajack.im> wrote:

> > If I apply the following function to 4 and 6
> >
> > (defn arith [x y]
> >  (map (fn [op] [(op x y) `(~op ~x ~y)]) [+ - / *]))
> >
> > I'd like to get a result of the form
> >
> > ([10 (+ 4 6)] [-2 (- 4 6)] ...)
> >
> > but instead I get something like
> > ([10 (#<core$_PLUS_ clojure.core$_PLUS_@4f6de641> 4 6)] ...
>
> You want to quote the [+ - / *] so it doesn't resolve to the functions:
>
> (defn arith [x y]
>  (map (fn [op] [(op x y) `(~op ~x ~y)]) '[+ - / *]))
>
> jack.
>
> --
> 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
>

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