I have two LinkedHashMaps with the same set of keys. I want to perform the dot product between them based on keys.
This is how I am currently doing it:
def dotProduct(a,b) {
acc = 0
a.keySet().each { acc += a[it] * b[it] }
acc
}
Is there a clearer/faster way?
You don't need acc.