这可能是非常简单的问题。我有一个名为“List1”的列表,其中包含以下整数对列表。scala和遍历列表中的所有第一元素和第二元素
的List1 =列表((1,2),(3,4),(9,8),(9,10))
输出应为:
R1 =(1,3,9,9)//列表((,2),(3 ,4),(9 ,8),(9 ,10))
R2 =(2,4,8,10)// List((1,),(3,),(9,),(9,))
array r1(Array[int]) should contains set of all first integers of each pair in the list.
array r2(Array[int]) should contains set of all second integers of each pair
感谢您提供这样精确的解决方案 –