I'd like to merge the list with or condition. For example,
List(List(1), List(2))
List(List(1), List(2), List(3))
List(List(2), List(3))
List(List(4))
Merge the above four lists to result values
List(List(1), List(2), List(3))
List(List(4))
I'd like to get a total of two lists.
list scala
Please keep that in mind
val a = List(List(1), List(2))
val b = List(List(1), List(2), List(3))
val c = List(List(2), List(3))
val d = List(List(4))
val mergeList = a ::: b ::: c ::: d
val splitList = mergeList.toSet.toList.splitAt(3)
splitList._1
// // List[List[Int]] = List(List(1), List(2), List(3))
splitList._2
// // List[List[Int]] = List(List(4))
© 2024 OneMinuteCode. All rights reserved.