Works for me:
user=> (map + [1 2 3] [4 5 6])
(5 7 9)
user=> (defn parallel [f l1 l2] (map (fn [x y] (f x y)) l1 l2))
#'user/parallel
user=> (parallel + '(1 2 3) '(4 5 6))
(5 7 9)
user=> (defn parallel [f l1 l2] (map f l1 l2))
#'user/parallel
user=> (parallel + '(1 2 3) '(4 5 6))
(5 7 9)
user=>
The problem seems to be that you are quoting the +. Not sure why this is, but:
user=> ('+ 1 4)
4
user=>
> I gleaned what I could from the Clojure wiki but I'm still missing
> something.
>
> Any pointers on where I am going wrong?
--
Michael Wood <esio...@gmail.com>
OK, I think I know why this happens. It's treating the '+ as the key
for a map, and using the second integer as the default value. I'm not
sure why it treats an integer as a map, though:
user=> (get {:a 1} :a)
1
user=> (get {:a 1} :b)
nil
user=> (get {:a 1} :b 2)
2
user=> (:a {:a 1})
1
user=> (:b {:a 1})
nil
user=> (:b {:a 1} 2)
2
user=> (:a 1 4)
4
user=> ('a 1 4)
4
user=> ('+ 1 4)
4
user=>
--
Michael Wood <esio...@gmail.com>
The problem seems to be that you are quoting the +. Not sure why this is, but:
user=> ('+ 1 4)
4
You've almost got it -- just don't quote the +:
user> (parallel + '(1 2 3) '(4 5 6))
(5 7 9)
By quoting the + you were passing in the symbol, not the function.
Dean