Just one more way to solve it but, getting a hash-map as a result....

(->> [[1 0.5] [1 0.7] [2 1.0] [3 0.1] [3 0.1]]
     (map (partial apply hash-map))
     (apply merge-with +))

Em quinta-feira, 19 de março de 2015 19:02:28 UTC-3, Ambrose 
Bonnaire-Sergeant escreveu:
>
> user=> (def a (group-by first [[1 0.5] [1 0.7] [2 1.0] [3 0.1] [3 0.1]]))
> #'user/a
> user=> (for [[k vs] a] [k (apply + (map second vs))])
> ([1 1.2] [2 1.0] [3 0.2])
>
>
> On Thu, Mar 19, 2015 at 3:41 PM, Alex <updat...@gmail.com <javascript:>> 
> wrote:
>
>> Hello everybody,
>>
>> How to transform sequence 
>>
>> *[[1 0.5] [1 0.7] [2 1.0] [3 0.1] [3 0.1]]*
>>
>> to
>>
>> *[[1 1.2] [2 1.0] [3 0.2]]*
>>
>> ?
>>
>> Best regards,
>> Alex
>>  
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> 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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to