想獲得分層turples的名單列表的列表清單,如何斯卡拉壓扁turples
val folders =List((1, (List(212, 2asdad), List(213, 2asdas))),
(2, (List(112, asasd), List(113, asasd6))),
...
)
val ouput = folders.zipWithIndex.map(sc => sc._1._2.map((sc._2, sc._1._1, _))).foreach(println)
//output = List((1, 212, 2asdad), (1, 213, 2asdas)),
// List((2, 112, asasd), (2, 113, asasd6)),
,但我感興趣的是得到一個分層列表這樣
//output = List((1, 212, 2asdad), (1, 213, 2asdas),
// (2, 112, asasd), (2, 113, asasd6)),
任何想法如何解決這個問題?
感謝
你的代碼是無效的...'['和']'都是仿製藥。你的意思是'val folders = List((1,List((212,2asdad),(213,2asdas))),(2,List((112,asasd),(113,asasd))),... '或'val folders = List((1,(212,2asdad),(213,2asdas)),(2,(112,asasd),(113,asasd)),...' –
@GáborBakos - I fixed感謝 –