平面贴图平面贴图是一种常见的组合,它将贴图“贴图”和扁平化“平面”组合在一起。 平面贴图需要一个处理嵌套列表的函数,用于合并结果。
scalavalnestednumbers=list (3(3,2 ),list (3,4 ) ) nested numbers 3360 list [ list [ int ] ]=list ) list 2 )2 4 ) scalanestednumbers.flat map (x=x.map (_ *2) ) RES0:list[int]=list ) 2、4、6、8 )表示“首先映射
scalanestednumbers.map (x : list [ int ]=x.map ) _*2).flattenRES1:list[int]=list ) 2、4、6、8