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)]) '[+ - / *]))
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
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
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
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
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_
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
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