I don't know if use of `partial' is considered idiomatic, but I think
it's the clearest in cases like this.

user> (def all-pairs '([ [1 2] [3 4] [5 6] ]  [[5 6] [7 8] [9 0]]) )
#'user/all-pairs
user> (apply map (partial map +) all-pairs)
((6 8) (10 12) (14 6))

-- Eric

Ulises <ulises.cerv...@gmail.com> writes:

>> A little stuck on how to do this efficiently.  I have data that looks
>> like this
>>
>> ( [ [1 2] [3 4] [5 6] ... ]  [ [5 6] [7 8] [9 0] ... ] ...)
>>
>> I am trying to sum the vector pairs, e.g
>>
>> [6 8] [10 12] [14 6]
>
> Try:
>
> user> (def all-pairs '([ [1 2] [3 4] [5 6] ]  [[5 6] [7 8] [9 0]]) )
> #'user/all-pairs
> user> (defn sum-vec [& pts]
>             (apply vector (apply map + pts)))
> #'user/sum-vec
> user> (apply map sum-vec all-pairs)
> ([6 8] [10 12] [14 6])
> user>
>
> U

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