Fork me on GitHub

Maybe this is an idiom I need to learn: I’d like to compare 2 maps, where keys match, just like a join. However, I don’t want to compare using equality, but a function that outputs a number between 0 and 1. Maybe too abstract right now, but shout out if this is a familiar thing.


@bocaj Sounds like you want to use merge-with, like (average (map #(if % 1 0) (vals (merge-with = m1 m2)))) (assuming you have an average function), if I understand you correctly.


Ah, thanks!


I’m working with 2 graphs, if that helps. Struggling a bit with the right structure


Make sure you have the same keys when using merge-with like that. It doesn't discard elements only found in one.


{:name {:weight nil :val "jones"} {:name {:weight nil :val "jone"} I think I could use merge with to set the weight with the result of

(compare "jones" "jone")