Counting occurences (solution to the exercise)
- What does
(merge-with + {:a 12} {:b 4} {:a 3 :b 7})
return? {:b 11, :a 15}
when there are several values for a key, these values are merged (two at a time) using the specified function — here they are summed.- Can you count occurrences of each value in a collection using
merge-with
? (apply merge-with + (map (fn [x] {x 1}) coll))
or, usingfor
:(apply merge-with + (for [x coll] {x 1}))
.
If you’re seeking a thrill – packed escape, look no further! 123b is the gateway to a world of excitement that’ll ignite your passion. Don’t hesitate, just click!
https://pg88.lifestyle
PG88 cung cấp kho trò chơi cá cược đa dạng cùng nhiều ưu đãi đầy …