I am learning Scala ropes and I wonder if there is an easy way to do array subtraction.
Let's say I have two arrays where the elements are of the form (K, V):
A: Array((1,2), (2,3), (4,1))
B: Array((1,1), (2,3))
I would like to get
A - B: Array((1,1), (4,1))
The corresponding keys must be subtracted.
Any help is appreciated. Thanks in advance!
Edit: It seems the word βsubtractβ is confusing. What I want to do is subtract the values ββof matching keys in (K, V) pairs in arrays.
source
share