If I have
val incomingIds : List[Int] = ....
val existingIds : List[Int] = //this makes db calls and find existing records (only interested in returning ids)
Now next I want to compare incomingIds
with existingIds
in a following way
say I have
val incomingIds : List[Int] = List(2,3,4,5)
val existingIds : List[Int] = List(1,2,3,6)
What above sample suggests is that my API should be able to find ids
that are subject for deletion (ones that exist in incomingIds
but not in existingIds
). In this sample existingIds
have 1,4,5
but they aren't there in incomingIds
means 1,4,5
should go into
val idsForDeletion :List[Int]
and there will be another list call it
val idsForInsertion :List[Int].
so 6
should go into idsForInsertion
list.
Is there a simple way to partition lists such a way?