|
So I have a list of tuples that looks like (a, (b, x)). I want as a result a map of a to (b, x) where x is the greatest x for that given a and b combo. Basically, if the x I'm examining is greater than the greatest x so far for that a as well as that b, update the result map with the a, (b, x) combo. I have legitimately no idea how to approach this. It seems like I should be able to do this with foldLeft, am I crazy?
|
# ¿ Oct 24, 2016 23:33 |
|
|
# ¿ May 12, 2024 08:22 |
|
Sedro posted:Good Thanks for this. Basically, my input is something like [ (A, (B, X)), (A, (C, X)), (A, (D, X), (A, (C, Y)), (A, (C, Z)))] and so on. It's a mapping of an Id, to tuples containing a value and a timestamp for that value. I have no choice as to how that's represented, but I do have some leeway over how I process it and reach my desire result of Map[A, (C, (maximum of X, Y, Z)]. This is one of the harder things I've done in Scala so far (I'm using Spark) but it's really neat and I'm enjoying it so far.
|
# ¿ Oct 25, 2016 15:20 |