Re: Resolving vars and quoting

2012-03-18 Thread Paul Carey
Many thanks for all the replies. Paul On Thu, Mar 15, 2012 at 10:49 PM, Stuart Campbell stu...@harto.org wrote: 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)]) '[+ - / *]))

Resolving vars and quoting

2012-03-15 Thread Paul Carey
Hi 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)] ... How do I

Resolving vars and quoting

2012-03-15 Thread Paul Carey
Hi 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)] ... How do I

Re: Resolving vars and quoting

2012-03-15 Thread Jack Moffitt
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

Re: Resolving vars and quoting

2012-03-15 Thread Stuart Halloway
As an aside, when playing around with quoting and unquoting, I noticed that the result of ('+ 3 5) is 5. I'm not sure what I would have expected (maybe an error?) but it wasn't the third item of the list. Is there any reason for this? From http://clojure.org/data_structures: Symbols, just

Re: Resolving vars and quoting

2012-03-15 Thread Tassilo Horn
Paul Carey paul.p.ca...@gmail.com writes: Hi 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_

Re: Resolving vars and quoting

2012-03-15 Thread Tassilo Horn
Tassilo Horn tass...@member.fsf.org writes: As an aside, when playing around with quoting and unquoting, I noticed that the result of ('+ 3 5) is 5. I'm not sure what I would have expected (maybe an error?) but it wasn't the third item of the list. Is there any reason for this? Symbol

Re: Resolving vars and quoting

2012-03-15 Thread Stuart Campbell
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