我有一个给定的Int(例如3)和一个元素列表。
我想将这些元素按3个列表排序(取决于给定的int)。
例如:3 [a,b,c,d,e,f,g] -> [[a,d,g],[b,e],[c,f]]
我只知道函数:
chunksOf 3 ['a'..'z']
["abc","def","ghi","jkl","mno","pqr","stu","vwx","yz"]
提前谢谢
答案 0 :(得分:3)
您要transpose:
transpose ["abc", "def", "g"]
给予
["adg","be","cf"]
您可以将其组合
transpose $ chunksOf 3 "abcdefg"